|
At design time you can set CellPadding and CellSpacing property of DataGrid - remember, the dataGrid renders its results in an HTML table, and these properties simply translate to those of the table.
You can set individual ciolumn widths at runtime using, for example:
DataGrid1.Columns(2).ItemStyle.Width = System.Web.UI.WebControls.Unit.Percentage(30)
This would change the third column to 30% of the overall width. You could use
...Pixel(100)
if you wanted to give it a fixed width of, say, 100 pixels instead.
cheers
Phil
|
|
|
|
|
Thanks for the response. CellPadding and CellSpacing will increase the height of the row which I don`t want. I could fix the width with percentage or pixels, but with variable length data, this method will only work sometimes.
What would be best is if there was a way to convert units to a number type and back. Then I could grab the width of a column, add some units to it and then convert it back.
Veeves
|
|
|
|
|
Hi,
I think u will have to check for ItemDataBound event of the datagrid for this purpose maybe check if u can get the current column width and then change it there only or adjust the text by inserting into the string to be bound to that column...
I haven't tried this yet...But just thought of sharing this idea...
Thanks for reading..
Thanks & regards,
Vaibhav
|
|
|
|
|
I want to fill datagrid in design view of page how to do that
|
|
|
|
|
You want to fill data in the datagrid in the design view window? Basically if you want to customize the UI of the control at design time, you can think of implementing a custom control designer, and you can read more about this in MSDN:
Design-Time Support for Web Forms[^]
|
|
|
|
|
Hi,
I have an ASP.NET application I've been developing using Visual Studio 2005 and therefore I've been using the built-in webserver for debugging. So far so good, and everything works as expected. The application includes a login page which uses the standard Login ctrl, and it uses a custom membership provider for Access (http://msdn.microsoft.com/vstudio/eula.aspx?id=96713a8e-b8d4-4d6e-bb8f-027e6c8e15d8[^]). However, when I deploy (just to the local IIS on my computer), the login stops working. I.e., when I try logging in supplying wrong username or password I get a "Invalid login" message. But if I supply a correct username and password, all I get it a "The page cannot be displayed". There is no indication of a redirect - after all, I set the Login control to just stay on the Login.aspx page after login succeedes. I've also tried to bypass the Login control, supplying my own username and password controls, and then adding the code myself which calls Membership.ValidateUser. The funny thing is, the try/catch block inside that function never catches anything, and even if my code looks like this:
if ( Membership.ValidateUser( strUsername, strPassword ) )
{
// No code in here!
}
the login *still* fails, i.e. it does not seem to matter if there is any code after the ValidateUser function call.
I honestly don't know what could be causing this but I have a feeling it could be something of the following:
- security, is someone (the membership provider) trying to write to the database and doesn't have the sufficient rights to do so? In that case, I should get an "Operation must use an updateable query" error, right?
- IIS configuration, is there something I haven't set correctly?
- something more I'm forgetting...
Anyway, I would welcome any help/ideas how to solve this!
Regards,
Daniel
|
|
|
|
|
HI Daniel. Wild guess - access permisions to write to the .mdb file, but also permissions to write to the .mdb file's containing folder. In my experience with Access databases, the aspnet_wp.exe process account needs access to read and write to the containing folder (presumably to allow the companion .ldb file to be written and updated as necessary). It's at least something to try.
|
|
|
|
|
I use AJAX in ASP.NET, in the client side code, I create a XmlHttpRequest to get data from Server(database). But when server response, how to get data from responseText or responseXML to fill in DataList or DataGrid(because DataList or DataGrid is control that run at server).
Thanks!
I sent this message in the last week, but noone answer, please help me.
|
|
|
|
|
hi,
i am sending u java script code which bind data into listbox through.
var obj
function PopulateList()
{
My.Page.ShowList(DoSetCallBack);
}
function DoSetCallBack(result)
{
if(document.Form1.ListBox1.options.length > 0)
{
document.Form1.ListBox1.options.length = 0;
}
var table = result.value.Tables.Table;
var listbox = document.getElementById("ListBox1");
if(table != null )
{
for (var i = 0; i < table.Rows.length; ++i)
{
var option = document.createElemet("option");
option.text = table.Rows[i].orderid;
option.value = option.text;
option.selected = false;
listbox.add(option);
}
}
}
|
|
|
|
|
Anyone know alot about them? I am fed up with the information being displayed as one long row that stretches away off the screen. Is there a way of making it 2 columns or even three but with the same data in it obviously.
Cheers
|
|
|
|
|
You could use TemplateColumns and put two, three, four (more?) fields worth of data in the same column.
|
|
|
|
|
Hopefully somebody can help with this or at least tell me it is possible
I have a VS 2005 project, the default page has a menu control, a multiview control and several views within this. When i click the menu item i use a case statement to make different views active, as shown;
protected void mnuMain_MenuItemClick(object sender, MenuEventArgs e)<br />
{<br />
string strMenu = "";<br />
strMenu = mnuMain.SelectedValue.ToString();<br />
<br />
try<br />
{<br />
switch (strMenu)<br />
{<br />
case "Home":<br />
MultiView1.SetActiveView(viewHome);<br />
break;<br />
<br />
case "Submit":<br />
MultiView1.SetActiveView(viewSubmit);<br />
break;<br />
<br />
case "System":<br />
ds = dba.ReturnDataSet("select * from system_status");<br />
grdSystem.DataSource = ds; grdSystem.DataBind();<br />
MultiView1.SetActiveView(viewSystem);<br />
break;<br />
<br />
default:<br />
MultiView1.SetActiveView(viewHome);<br />
break;<br />
}<br />
}<br />
catch (Exception exp)<br />
{<br />
string exception = exp.ToString().Replace("\n", "");<br />
Response.Redirect("error.aspx?error=" + exception);<br />
}<br />
}
When the user clicks the menu item 'System' i want to connect to a database using a class i created called dba and the function ReturnDataSet. I then want to bind this to a gridview control called grdSystem, which is located in the View control 'System' and make this View the active view.
This code complies and runs with no errors and the dataset has the correct number of rows returned.
But the gridview inside the View is not displayed and on walking through the gridview has no items in it. (I tested with a gridView which was not inside a view and the contents as displayed ok so i think it is something to do with refreshing the view control??)
Hopefully this makes sense and somebody can tell me if this is possible?
Thanks
Colin
-- modified at 7:19 Tuesday 18th April, 2006
|
|
|
|
|
Have you tried to place text or another simple control like Label along with the GridView in the System view and see if the active view is actually refreshed?
|
|
|
|
|
I can update the text propery of a label just after I do the bind and it shows the update.
I can also add all the items in the dataSET to a dropdownlist and it shows.
It is just the gridView which does not show the update - as if the bind has not worked.
Thanks
Colin
|
|
|
|
|
Hmm, is there any chance that the Grid control is rebound somewhere else in the web page? Here on my machine, I simply have two view with one containing a GridView control, every time I switch to that view I can see the gridview control displayed.
|
|
|
|
|
not sure what was going wrong but re-created the grid view and binding was succesfull
GridView is displayed as expected
Thanks
Colin
|
|
|
|
|
Hi
I am trying to print 2 substrings of a textbox but i get this error
MY CODE IS :
---------------
If Not TextBox1.Text = "" Then
str = TextBox1.Text.Substring(0, 3)
str1 = TextBox1.Text.Substring(3, TextBox1.Text.Length - 1)
End If
But it is giving error
-----------------------
Index and length must refer to a location within the string. Parameter name: length
Help me
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
|
|
|
|
|
If you look at the definition of the Substring method you will see thatthe second parameter is the length you want...not the end position.
You are trying to read from position 3 to (length-1) which will always be past the end of the string.
If you want to read everything until the end, there is an overriden version of substring method that just takes the start position.
|
|
|
|
|
Sorry i didnt get u r point sir...
How can i print that 2 values
or
any other idea to substring
thx for replying
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
|
|
|
|
|
If you read the documentation on Substring[^] you will see that there are 2 versions of it. One takes start position and length, the other just takes start position[^], For your str2 you want the latter. which will give you everything from start position onwards.
Also, please do not to use txtspk in these forums.
|
|
|
|
|
Hi, I m working with asp.net 2.0. I set the GridView.DataKeys as ID. When I click on Update button. the updating event is raised. But in the e.Keys/NewValues/OldValues there is always 0. But I get the rowindex of hte row i edited.
I think i didn't set any property of gridview. thats why i don't get value in e.NewValues Property
Please help
|
|
|
|
|
Since I don't see your sample code, so IMO you may want to check a couple of properties:
+ The DataKeyNames property of the GridView control.
+ Do you use the BoundField or TemplateField with the data binding expression in the GridView control? If you use the expression, make sure it support two-way data binding.
+ Do you any datasource control with the GridControl? If yes, check the ConflictDetection property.
You can see more details in MSDN[^]
|
|
|
|
|
My problem was i didn't attached an objectdatasource to the gridview. I was only getting RowIndex in the RowUpdating event.
As i was not able to get the newValues,oldValues/Keys, I attached an objectdatasource(which is attached .dll file) to the gridview control. Now when i click on update link on the gridview, I get the newValues,oldValues/Keys.
If i want to get access to newValues,oldValues/Keys in a RowUpdating event of a gridview/detailsview, do i have to always assign an objectdatasource.
|
|
|
|
|
sohne wrote: If i want to get access to newValues,oldValues/Keys in a RowUpdating event of a gridview/detailsview, do i have to always assign an objectdatasource.
Yes, you do. If you don't specify the datasource in the DataSourceID property of the control, you only have the row index value in the event data argument GridViewUpdateEventArgs .
|
|
|
|
|
Hi
I'm using a asp.net web based application builder (ework) that provides an interface to write jscript.net static functions. (shared)
In the function, I am calling a web service via a proxy created in visual studio. I have set the URI in the proxy to be dynamic which has created an app.config file. All this is working in dev.
Now that I'm moving to test, I've copied the App.config to the directory with the Web sevice proxy dll (CIServiceProxy.dll) and renamed the file to CIServiceProxy.dll.config however, it is not picking up the revised uri for the web service.
Is this because the process is running within a web application? or the functions called are Static or I've done something silly.
Is there an alternative way of making the webservice uri dynamic?
cheers
G Field
|
|
|
|