473,569 Members | 2,729 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 1703
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******** ******@tk2msftn gp13.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.RowFil ter property and the DataTable.Selec t 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******@onlin e.microsoft.com > wrote in message
news:ft******** ******@cpmsftng xa07.phx.gbl...
Hi Tim,

I agree with Prateek that you can filter the records. In ADO.NET, you can
use the DataView.RowFil ter property and the DataTable.Selec t 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******** ******@TK2MSFTN GP11.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******@onlin e.microsoft.com > wrote in message
news:ft******** ******@cpmsftng xa07.phx.gbl...
Hi Tim,

I agree with Prateek that you can filter the records. In ADO.NET, you can
use the DataView.RowFil ter property and the DataTable.Selec t 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
2272
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 inside the SP (to manipulate data), the data that comes out of the SP can not be displayed in the datagrid. In this case only the first row shows up...
5
12214
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. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate...
4
3727
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
1453
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 be loading a different usercontrol-2 based on the selections in usercontrol-1. Also I thought of passing the selection values through
3
2816
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 there any way I can optimize the speed. Any sample code would be great. Thanks, Reddy
4
3274
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 and I need to implement some kind of "client side" lazy loading. What I mean is this: I want to display a grid that only shows, say, 20 records....
1
1412
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 code for it, but my problem is that it doesn't work unless i click on an empty button, just to reload the page... also how would i control the...
1
2344
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 visible till the data is entirely loaded. Is there a way to prevent that? e.g. referesh the screen before loading starts or allow the file chooser...
1
1802
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 any other method to make it fast loading bala code:
7
5375
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 GridViewRow(0,0,DataControlRowType.DataRow, DataControlRowState.Normal); TableCell myCell = new TableCell(); TextBox myTextbox = new TextBox(); myTextbox.Text = "hello world";...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.