Gridview sorting with objectdatasource and dataset - help!

edmicman

Golden Member
May 30, 2001
1,682
0
0
I have a gridview that I'm populating via ODBC. I'm using an objectdatasource, and have a class that returns a dataset with the results. I've got everything working great, but Management feels that the sorting on the gridview is unacceptably slow. It looks like it's requerying the database on the sort, and they're nitpicking about those extra few seconds. Anyway, is this for sure what's happening? Is there a way to diconnect the dataset from the database and have the gridview just sort in memory to speed things up? Are there any other options? Thanks for any help - this is my first .NET 2.0 application, and I'm learning a lot, but I'm not really sure where to go from here. Thanks!
 

beggerking

Golden Member
Jan 15, 2006
1,703
0
0
did you use a data adaptor with your gridview control? with data adaptor it'll be a disconnected dataset.. The only thing is that you'll need to fill it everytime you need new information.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
You could store the results in your session which would alleviate the need to query the database on every sort. However, that's a huge memory hog.

How many records is your query returning? Are you using paging? If it's anything large, you really don't want to be returning it all to the client if you're only displaying part of it at a time. It would be far, far faster to do a paged query (select top X...) so that you're not sending a ridiculous amount of stuff over the wire every time. And unless the db is already under much heavier load than the web server, it will do faster sorts, so long as you have decent indexes set up (do you?). The only downer there is that you lose a bit of the gridview's inbuilt paging handiness.
 

edmicman

Golden Member
May 30, 2001
1,682
0
0
I have an OdbcDataAdapter that is filling the dataset in the class. But the dataset is ultimately bound to the GridView. Would the gridview sorting work on the dataadapter? I.e., would it be able to sort the dataadapter in memory then?

Or, is there a way I can have the gridview only fill the dataset once, and then sort in memory? I'm still trying to grasp the whole gridview thing....it almost looks like the sorting is all done on the server side, requerying whatever data with the sort parameter. Will it even do any sorting without passes to the database?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I believe you can define a sorting callback on the gridview (I'm pretty new to asp.net myself) and maybe you can define your own in memory sort there. You'd also have to cache the dataset in session memory.

But, as stated above, if you're dealing with large amounts of data, doing everything on the webserver is a Bad Idea (tm).
 

edmicman

Golden Member
May 30, 2001
1,682
0
0
Originally posted by: kamper

But, as stated above, if you're dealing with large amounts of data, doing everything on the webserver is a Bad Idea (tm).

You think? You'd think they'd realize that databases are better suited for sorting and all, and they'd be able to be patient enough for the 1-1.5 seconds a sort is taking. Bah! Right now I've got about 20 records being returned, and the sorting (to run back to the database and back) takes about 1-2 seconds. I've implemented the multicolumn sort from here (http://aspalliance.com/666), because they want to sort on multiple columns, and it was a very easy extension of the existing gridview. I'm using Atlas to handle things, so there's no page flicker, but that keeps me from using the enablesortingandpagingcallbacks on the gridview itself. But it works. It's just slow - and I'm pretty sure thats because of the ghetto ODBC driver we're having to use (KB_SQL for a STAR database).

While I could probably put the results in a session variable now, supposedly we can get hundreds of results back. They also don't want me to implement paging, either. Hmmmmm, maybe I'll check on that though and see if it speeds things up any.

What pains me is that the stupid thing is working, it's just not as "snappy" as they'd like. Maybe I should put the visible postback in for them and they can use it then :-/