Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DC - 08 Feb 2008 14:52 GMT
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
bruce barker - 08 Feb 2008 16:23 GMT
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)

> Hi,
>
[quoted text clipped - 21 lines]
> Thanks a lot for any hints in advance! Regards
> DC
DC - 11 Feb 2008 17:54 GMT
On 8 Feb., 17:23, bruce barker <brucebar...@discussions.microsoft.com>
wrote:
> using viewstate works the same way. with viewstate the data is serialized to
> viewstate, in onload viewstate, its deserialized, then databound.
[quoted text clipped - 32 lines]
>
> - 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.