473,503 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a datagrid

Hi,

I want to display the contents of a table in a datagrid. However I don't
want to load all the rows before presenting it to the user. Is there a way I
can load the datagrid a page at a time, load the next page as the user
scrolls down.

Tim
Nov 22 '05 #1
4 1696
Hi Tim,

You can use the Fliter method on the DataTable's primary key column. e.g.
Filter top 100 records on the primary key column and bind these to the
DataGrid. When you want to show next set of records, modify the filter
accordingly and bind again.

Or, you can modify the SQL query and fetch records between a certain row
number. Again, when you want to show the next set of records, modify the row
number range in the query, refetch and rebind.

Let me know if this was helpful.

-Prateek

"Tim Marsden" <TM@UK.COM> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Hi,

I want to display the contents of a table in a datagrid. However I don't
want to load all the rows before presenting it to the user. Is there a way I
can load the datagrid a page at a time, load the next page as the user
scrolls down.

Tim

Nov 22 '05 #2
Hi Tim,

I agree with Prateek that you can filter the records. In ADO.NET, you can
use the DataView.RowFilter property and the DataTable.Select method to
filter a subset of records. Please refer to the following articles and
samples for detailed information on this subject:

Filtering and Sorting in ADO.NET
http://www.akadia.com/services/dotnet_filter_sort.html

HOW TO: Perform a Complex Filter in ADO.NET
http://support.microsoft.com/?id=321896

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #3
Hi
Thanks for the response,

I only want to fetch the minimal amount of data from the database. Is it the
case with ADO that I have to populate the whole of the datatable before
applying the filter?. This defeats the object of trying to improve
performance.

Tim.
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:ft**************@cpmsftngxa07.phx.gbl...
Hi Tim,

I agree with Prateek that you can filter the records. In ADO.NET, you can
use the DataView.RowFilter property and the DataTable.Select method to
filter a subset of records. Please refer to the following articles and
samples for detailed information on this subject:

Filtering and Sorting in ADO.NET
http://www.akadia.com/services/dotnet_filter_sort.html

HOW TO: Perform a Complex Filter in ADO.NET
http://support.microsoft.com/?id=321896

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #4
Yes, in this scenario you will need to fill the whole DataTable.

If you dont want to populate the whole datatable, then use my second option.
i.e. fetch only certain number of records each time.

e.g. if you have a table called MyTable and a PK field called ID which runs
from say 10000 to 12000 AND you want to show only 100 records each time
then,

iMin = 10000
iMax = 10100
SQL = "select * from MyTable where ID >= " & iMin & " and ID <= " & iMax
'Fill the datatable using this statement

'Now when you want show the next page

iMin = iMin + 100
iMax = iMax + 100

SQL = "select * from MyTable where ID >= " & iMin & " and ID <= " & iMax
'Fill the datatable using this statement
Hope this helps

- Prateek
"Tim Marsden" <TM@UK.COM> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
Hi
Thanks for the response,

I only want to fetch the minimal amount of data from the database. Is it the
case with ADO that I have to populate the whole of the datatable before
applying the filter?. This defeats the object of trying to improve
performance.

Tim.
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:ft**************@cpmsftngxa07.phx.gbl...
Hi Tim,

I agree with Prateek that you can filter the records. In ADO.NET, you can
use the DataView.RowFilter property and the DataTable.Select method to
filter a subset of records. Please refer to the following articles and
samples for detailed information on this subject:

Filtering and Sorting in ADO.NET
http://www.akadia.com/services/dotnet_filter_sort.html

HOW TO: Perform a Complex Filter in ADO.NET
http://support.microsoft.com/?id=321896

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 22 '05 #5

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

Similar topics

1
2270
by: Merdaad | last post by:
In my datagrid, I call my SP and if I only have a simple select statement, everything comes back fine and all rows get displayed in datagrid using datasource and databind But if I use a cursor...
5
12208
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
4
3719
by: Jonas Nilsson | last post by:
How can i show a "Wait while loading..." text on my aspx page while loading data into a datagrid from a database. /Jonas
1
1450
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a datagrid in the user control-2, Also the I could...
3
2810
by: Reddy | last post by:
The sql query for my datagrid returns 100, 000 records. But the datagrid should display 20 records per page. I am using datagrid paging, but it is taking too much time for the page to load. Is...
4
3259
by: blackhawk | last post by:
I need to build a web page that has to potentially display a large amount of data in two grids on the same page. The HTML file with all of the formatting is about 7MB in size. This is too large...
1
1407
by: ACaunter | last post by:
Hi all, Could someone please explain to me how i could load a different datagrid or fill out all the textboxes with feilds from a database - once a user types a character in a textbox. I have the...
1
2343
by: alex | last post by:
Hi, I am loading quite a large list into a datagrid and while doing so the form freezes... and for 10-20 seconds i have quite a messy screen. e.g. the file chooser half deleted and still half...
1
1794
by: Bala | last post by:
Hi, Currently i am loading the file names into datagrid (unbound) from a folder(sub folders too). so for this i am using this below code. but its too slow to loading all the file names. is it...
7
5372
by: GaryDean | last post by:
I'm trying to load a GridView up with data manually, in code. I'm not using any datasource. Using this code.... ArrayList myRowArrayList; GridViewRow myGVR = new...
0
7086
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
7330
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...
1
6991
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
7460
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
5578
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
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...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.