What is the best way to sort a datagrid (asp.net) that uses stored procedures?
Posted on 2004-09-02
I have a page that displays data in a datagrid. In the page_load event, after looking into Request.Params(), I determine an appropriate stored procedure to use. I invoke the storeproc, using MS application blocks, and bind the datagrid's datasource to a SqlDataReader.
I could think of the following options:
1) Use a dataview and bind the grid to the dataview. Sorting can be accomplished by sorting the dataview. <b>My question here is how do I create a dataview from SqlDataReader. I am not using DataSet.</b>
2) Based on the sort column, call the storeproc with the sort column as a parameter. The downside to this option is, I would have to determine again which stored procedure to invoke.
Which option do you like, and are there other easier options available?