Groups | Blog | Home
all groups > asp.net webcontrols > june 2004 >

asp.net webcontrols : typed DataSet-bound DataGrid sorting


Whugster
6/29/2004 9:44:13 AM
Hi. I have a DataGrid bound to a typed DataSet and I just couldn't figure
out how to sort the damn thing. I tried setting the Sort property of the
DataTable.DefaultView and the Attributes["SortExpr"] of the DataGrid but I
think the order of events matter. Here's a breakdown of events:

1. Page_Load:
- call my method LoadGrid( )
- call Page.DataBind( )

2. my method LoadGrid:
- set mytypeddataset = MethodThatGetsFilledDataSet( )

3. SortCommand grid event handler:
- mytypeddataset.Tables["MyTable"].DefaultView.Sort = "somesortstring"


Whugster
6/29/2004 10:00:11 AM
Yea that seems to be the problem because binding to a typed dataset happens
underneath. I just dragged and dropped a DataView object to the page and
bind from that object. The solved it. Thanks.


[quoted text, click to view]

MattC
6/29/2004 2:50:31 PM
I'm pretty sure you want binding to be the last thing that is done, i.e,
have your dataset sorted then bind it to the grid for displaying.

MattC
[quoted text, click to view]

AddThis Social Bookmark Button