473,395 Members | 1,516 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,395 software developers and data experts.

Populating a datgrid on demand

Hi,
My problem is this, I have a search screen which creates a query that
performs a search on a large database. The results of this search could, if
the user requires, return many many rows (20,000).....

In other languages, when faced with this problem, you can run a query and
link it to a datasource and link the datasource to a table. You can then set
an option called packetrecords to 20. If your grid has 40 rows, then as it
populates it will cause the query to return another batch of rows from the
cursor to populate the grid . As you scroll down the grid rows are fetched
each time "on demand" until the cursor is fully returned. This means that
the entire 20,000 rows aren't retrieved from the dataset and reduces traffic
and speeds up the grid..

I cannot seem to achieve the same effect to populate a grid (at least that
easily anyway) without having to create a virtual grid and write a lot of
code.
I know using a datareader and performing a read() doesn;t return a whole
cursor at once as I have tested it using the sql profiler - so I was hoping
that someone knows the magic property i need to set to populate a gridview
this way....

regards to all

Dave.
Jul 31 '06 #1
1 1519
In addition,

What I have at the moment is a listview. I open an sqlcmd and create a
datareader on it. It the listviewselectionchanged I execute the following
code...

if (e.ItemIndex == listView1.Items.Count-1)
{
for (int ctr = 0; ctr <= 10; ctr++)
{
if (allSQLObjects.Read())
{
additem(allSQLObjects["Surname"].ToString(),
allSQLObjects["Name"].ToString());
}
}
}

This causes another 10 records to be read from the cursor and the listview
grows. If you keep you finger on the down arrow - then eventually the
listview will be full.

I will also add a close() for the data reader and tidy the code up a little
more, and may do mouse down events to call this code when they scroll etc.

If anyone has a better method for doing this I would be greatful - as to
populate a grid with 20,000 records a user may not want to see will take a
while - when the chances are they will find what they are looking for if the
data is sorted correctly in the first 100 or so.. Trying to work out if a
user is going to return too many rows is not ideal - so if I can fill the
display with 10 (or 100) at a time it would be great..
--
regards
Dave Hutchings
"Dave Hutchings" wrote:
Hi,
My problem is this, I have a search screen which creates a query that
performs a search on a large database. The results of this search could, if
the user requires, return many many rows (20,000).....

In other languages, when faced with this problem, you can run a query and
link it to a datasource and link the datasource to a table. You can then set
an option called packetrecords to 20. If your grid has 40 rows, then as it
populates it will cause the query to return another batch of rows from the
cursor to populate the grid . As you scroll down the grid rows are fetched
each time "on demand" until the cursor is fully returned. This means that
the entire 20,000 rows aren't retrieved from the dataset and reduces traffic
and speeds up the grid..

I cannot seem to achieve the same effect to populate a grid (at least that
easily anyway) without having to create a virtual grid and write a lot of
code.
I know using a datareader and performing a read() doesn;t return a whole
cursor at once as I have tested it using the sql profiler - so I was hoping
that someone knows the magic property i need to set to populate a gridview
this way....

regards to all

Dave.
Aug 1 '06 #2

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

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
2
by: Janus | last post by:
Hello. I need a little advice for populating the treeview control. I dont want my application to hang while populating the treeview, there is a lot of data what's the best approach? Maybe...
1
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
1
by: menyki | last post by:
am writing a program to determine the best price that will attract maximum demand. first i had to generate random number to enable me determine the price and quantity demanded at the particular...
2
by: 1980dinesh | last post by:
Hi, I have a DatGrid and i have added a checkboxes as template column i have write javascipt code to check and unckeck but at button event of code behind i can't grab the (checked) true condition...
6
by: vunet.us | last post by:
I have an HTML page with included JS file like: <script language="javascript" type="text/javascript" src="file.js"></ script> The file.js has a set of functions and global initializer for some...
0
by: Eric B. | last post by:
I am populating a DataGrid with many rows. As it is populating I see the scrollbar flying but no rows pop up until it is finished. Is there a way to make each row draw as soon as it is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.