Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid - Sorting & Paging

Reply
Thread Tools

DataGrid - Sorting & Paging

 
 
pmanno
Guest
Posts: n/a
 
      05-06-2005
If I have a page with a DataGrid that is bound to a DataTable that is
populated by a query to a database and I want to enable sorting and
paging, do I have to add the DataTable to the cache or will the
viewstate hold the contents of the DataTable?

Basically, I want to avoid hitting the database wherever I can. It
seems that the DataTable has to be cached and the DataGrid re-bound, or
the DataTable has to be re-populated from the database and the DataGrid
re-bound whenever a postback occurs since the DataTable and therefore
the data which is bound to the grid is discarded once the page renders.

Thanks.

 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      05-06-2005
Viewstate will only hold the contents of the grid. By contents I mean the
HTML generated to display the contents of the data source.

The datatable itself will not be there. So you have to recreate it, sort,
and rebind.

"pmanno" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> If I have a page with a DataGrid that is bound to a DataTable that is
> populated by a query to a database and I want to enable sorting and
> paging, do I have to add the DataTable to the cache or will the
> viewstate hold the contents of the DataTable?
>
> Basically, I want to avoid hitting the database wherever I can. It
> seems that the DataTable has to be cached and the DataGrid re-bound, or
> the DataTable has to be re-populated from the database and the DataGrid
> re-bound whenever a postback occurs since the DataTable and therefore
> the data which is bound to the grid is discarded once the page renders.
>
> Thanks.
>



 
Reply With Quote
 
 
 
 
John Timney \(ASP.NET MVP\)
Guest
Posts: n/a
 
      05-06-2005
You need to add it to the cache, then re-sort it each page load

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"pmanno" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> If I have a page with a DataGrid that is bound to a DataTable that is
> populated by a query to a database and I want to enable sorting and
> paging, do I have to add the DataTable to the cache or will the
> viewstate hold the contents of the DataTable?
>
> Basically, I want to avoid hitting the database wherever I can. It
> seems that the DataTable has to be cached and the DataGrid re-bound, or
> the DataTable has to be re-populated from the database and the DataGrid
> re-bound whenever a postback occurs since the DataTable and therefore
> the data which is bound to the grid is discarded once the page renders.
>
> Thanks.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
datagrid paging - customising paging style wh1974 ASP .Net 0 01-12-2005 03:48 PM
Programatically add sorting and paging to a datagrid =?Utf-8?B?bWc=?= ASP .Net 1 05-27-2004 01:55 PM
Datagrid custom sorting and paging using stored procedure Mo ASP .Net 1 01-30-2004 07:56 PM
DataGrid - sorting/paging problem Hajime Kusakabe ASP .Net 2 07-31-2003 05:18 AM



Advertisments