GridView: sort && avoid outdated data && trip to database only once

D

DC

Hi,

I am using the GridView and other databound controls a lot to present
realtime data, so I cannot use ViewState but instead must always get
fresh data from sql server whenever the user triggers an action like
resorting the grid.

I am using the typical events for sorting and I thought with ASP.Net
2.0 a ControlState was introduced, which allows to handle such events
with EnableViewState=false. But when I disable ViewState the event
does not get fired, just like it used to be in ASP.Net 1.1.

So currently when somebody resorts, I am binding the grid once in
order to set it up correctly an fire the event, and then I am tripping
to the database again and binding it a second time to the updated and
resorted data.

Can I avoid the second trip?

I am probably a halfwit but I am running into similar "double-load"
issues quiet often. Maybe someone knows a resource with best practises
concerning this affair.

Thanks a lot for any hints in advance! Regards
DC
 
B

bruce barker

using viewstate works the same way. with viewstate the data is serialized to
viewstate, in onload viewstate, its deserialized, then databound.

you can store the data in session and rebind from it in oninit, but if you
use sqlserver session, then the requery may be a good option. if if inproc,
you ay want to do the query to save memory load on the server.

-- bruce (sqlwork.com)
 
D

DC

using viewstate works the same way. with viewstate the data is serialized to
viewstate, in onload viewstate, its deserialized, then databound.

you can store the data in session and rebind from it in oninit, but if you
use sqlserver session, then the requery may be a good option. if if inproc,
you ay want to do the query to save memory load on the server.

-- bruce (sqlwork.com)











- Zitierten Text anzeigen -

Thank you, Bruce. I tried to use viewstate, trading more transfer
(about 50 - 100K per request in my scenario) for the additional trip
to the database. However, I cannot get it to work. I am creating
columns dynamically, so I made sure to have the gridview set up before
viewstate loads (in OnInit). But still my result is an empty grid
after postback (empty datafields, but the rows and cols are there).

So I am still going to the DB twice for every request, and the first
DB query runs only for the recreation of the table state which is only
required to make events work. If I could hardwire the events (so the
recreted control would not be used) then I could avoid the seconds
call. But the only way of "hard wiring" I know is an ordinary anchor
and url parsing, which is impossible in my scenario since the gridview
also resides in an asp.net ajax updatepanel...

Regards
DC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top