Monday, April 20, 2009

gridview sorting without datasource

This is the first link any search on the topic yields: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource

For those of you scratching your heads wondering how he is able to pull the DataSource out of viewstate/thin air like that (a couple of people on that page seem to wonder too)

The answer is seen in the full solution given by the same source
He assigns to the DataSource in Page_Load :)

In short, the way to page and sort a gridview is the same as what you've been doing for datagrids all these years if you're using your own data binding logic.
I haven't yet seen a way to use GridView.SortDirection/SortExpression to do the job.

No comments:

Post a Comment