473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

DataGrid - Sorting & Paging

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.

Nov 19 '05 #1
2 1337
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" <pg*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr 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.

Nov 19 '05 #2
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" <pg*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr 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.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stanley Cheung | last post by:
Hi all, How can I import a csv file and display as a datagrid directly. Now, I am using datatable to bind to datagrid, but I got the problem for sorting and paging, i don't know how to make a...
2
by: Hajime Kusakabe | last post by:
Hi. I have created a datagrid (datagrid1) without any columns on a aspx page. Then aspx.vb adds columns from a database. It is somthing like this .... ================================== Dim...
1
by: Pums | last post by:
Hi All For one page I want to implement sortng as well as paging. Curretly that page is using datagrid for data binding and sorting. Datagrid supports attributes like sortexpression and sort order...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
2
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional...
2
by: Kuldeep | last post by:
Hi All, I have been trying to find some algorithms for datagrid sorting and paging. Please help Regards Kuldeep
3
by: Toni | last post by:
In DataGrid and GridView I can't use paging and sorting. I am connected to database with code, not visual. Can I use paging and sorting if I populate data to grid with code, or I need to drag and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.