Last post Jun 17, 2011 10:20 AM by superguppie
Jun 17, 2011 08:24 AM|dotnet16|LINK
I have a gridview in my aspx page.On the page_load i will be adding the boundfields to it.Now,based upon the value selected from a dropdown I need to change the order in which the columns arde displayed.Is it possible.
Please let me know your suggestions.
Jun 17, 2011 08:28 AM|hassanmehmood|LINK
On the page_load i will be adding the boundfields to it
When you will choose from dropdownlist and will postback to make changes, you will need to do the same what u just did above.
Means adding those columns again (but this time in the order mentioned in your dropdownlists)
Hope this helps..
Jun 17, 2011 08:34 AM|bhupalb|LINK
hi it is possible with the follwoing method of columns of table
change the order
Jun 17, 2011 09:11 AM|dotnet16|LINK
This is for DataTable right?Does such a property exist for GridView?
Jun 17, 2011 09:34 AM|bhupalb|LINK
ya it is DataTable only while assigning the datatable to grid view apply that function and assign to the grid view
Jun 17, 2011 10:20 AM|superguppie|LINK
On the page_load i will be adding the boundfields to it.
Don't. If you want PostBacks to work properly, they need to be added in the Init Phase. Use Page_Init if you can.
Now,based upon the value selected from a dropdown I need to change the order in which the columns arde displayed.Is it possible.
GridView will build rows during DataBind. The Cells will be ordered in accordance with the Columns. So if you order Columns right, and then DataBind, that should work.
One snag, though. As said, to make PostBack work properly, you need to add the Columns in the Init Phase. The order in that will have to match that of the last request. And you will not have the value of the DropDownList available at that time. Also, in
the Init Phase ViewState may not be available for use yet. Not sure how I would go about this. It's not easy.