473,698 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does PagedDataSource work?

Hi,

If my ProjectTable contains a lot of rows, each time I call the following
code, will all the rows be fetched? Or only those 5 records for that page
are fetched only?

/* -- code start -- */
OdbcConnection connection = new OdbcConnection( "DSN=Whatever") ;
connection.Open ();
string query = "SELECT * FROM ProjectTable";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter (query, connection);
DataSet dataSet = new DataSet();
dataAdapter.Fil l(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource ();
pagedDataSrc.Da taSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.Al lowPaging = true;
pagedDataSrc.Pa geSize = 5;

setPageIndex();

MyRepeater.Data Source = pagedDataSrc;
MyRepeater.Data Bind();
/* -- code end -- */

Thanks,
Franz
Jan 3 '06 #1
3 2917
PagedDataSource presents a paged view of data. The data in reality is always
all there in your datatable/dataset. However, any object binding to the data
through the PagedDataSource , will only see one page of the data at a time.

So, in the case of a datalist, the datalist will see just the 1 page of
data. It will only display that 1 page of data on the screen when it binds
to the PagedDataSource .

In the underlying datatable, however, all the records that were fetched from
the database are there.

This object is for data presentation purposes. It does not alter what
records actually get fetched from the DB. If you fetched 10K records, all
10K will be in memory. But if your page size is 20, the user will see 20
records at a time on the screen.

"Franz" <fr*******@i-hate-spam.com> wrote in message
news:u$******** *****@TK2MSFTNG P09.phx.gbl...
Hi,

If my ProjectTable contains a lot of rows, each time I call the following
code, will all the rows be fetched? Or only those 5 records for that page
are fetched only?

/* -- code start -- */
OdbcConnection connection = new OdbcConnection( "DSN=Whatever") ;
connection.Open ();
string query = "SELECT * FROM ProjectTable";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter (query, connection);
DataSet dataSet = new DataSet();
dataAdapter.Fil l(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource ();
pagedDataSrc.Da taSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.Al lowPaging = true;
pagedDataSrc.Pa geSize = 5;

setPageIndex();

MyRepeater.Data Source = pagedDataSrc;
MyRepeater.Data Bind();
/* -- code end -- */

Thanks,
Franz

Jan 3 '06 #2
Does that mean my code is not performance-oriented?
Should I modify the query so that it only fetches the records needed?

"Marina" <so*****@nospam .com> ¼¶¼g©ó¶l¥ó·s»D: eA************* @TK2MSFTNGP09.p hx.gbl...
PagedDataSource presents a paged view of data. The data in reality is
always all there in your datatable/dataset. However, any object binding to
the data through the PagedDataSource , will only see one page of the data
at a time.

So, in the case of a datalist, the datalist will see just the 1 page of
data. It will only display that 1 page of data on the screen when it binds
to the PagedDataSource .

In the underlying datatable, however, all the records that were fetched
from the database are there.

This object is for data presentation purposes. It does not alter what
records actually get fetched from the DB. If you fetched 10K records, all
10K will be in memory. But if your page size is 20, the user will see 20
records at a time on the screen.

"Franz" <fr*******@i-hate-spam.com> wrote in message
news:u$******** *****@TK2MSFTNG P09.phx.gbl...
Hi,

If my ProjectTable contains a lot of rows, each time I call the following
code, will all the rows be fetched? Or only those 5 records for that page
are fetched only?

/* -- code start -- */
OdbcConnection connection = new OdbcConnection( "DSN=Whatever") ;
connection.Open ();
string query = "SELECT * FROM ProjectTable";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter (query, connection);
DataSet dataSet = new DataSet();
dataAdapter.Fil l(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource ();
pagedDataSrc.Da taSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.Al lowPaging = true;
pagedDataSrc.Pa geSize = 5;

setPageIndex();

MyRepeater.Data Source = pagedDataSrc;
MyRepeater.Data Bind();
/* -- code end -- */

Thanks,
Franz


Jan 3 '06 #3
Well, there are 2 sides to performance.

The first is the number of rows you fetch from the database.

The second is the size of the page you stream down to the client. If you
have to display 10K rows worth of data on a page all at once, obviously that
will take a long time to download, it will take a very long time for the
browser to parse and render the resulting HTML, not to mention the page will
be virtually unusable to the user.

Paging data using the PagedDataSource class resolves the second issue.

The first issue is not at all related to PagedDataSource , since that happens
before the paging is applied. By the time PagedDataSource is applied to a
datasource, obviously all the data has already been fetched - unless you
modify your SQL query, which you had not. So there is no way for it to help
there.

So, you are on your own regarding fetching only the relevant rows from the
database.

"Franz" <fr*******@i-hate-spam.com> wrote in message
news:ux******** ******@TK2MSFTN GP11.phx.gbl...
Does that mean my code is not performance-oriented?
Should I modify the query so that it only fetches the records needed?

"Marina" <so*****@nospam .com>
¼¶¼g©ó¶l¥ó·s»D: eA************* @TK2MSFTNGP09.p hx.gbl...
PagedDataSource presents a paged view of data. The data in reality is
always all there in your datatable/dataset. However, any object binding
to the data through the PagedDataSource , will only see one page of the
data at a time.

So, in the case of a datalist, the datalist will see just the 1 page of
data. It will only display that 1 page of data on the screen when it
binds to the PagedDataSource .

In the underlying datatable, however, all the records that were fetched
from the database are there.

This object is for data presentation purposes. It does not alter what
records actually get fetched from the DB. If you fetched 10K records, all
10K will be in memory. But if your page size is 20, the user will see 20
records at a time on the screen.

"Franz" <fr*******@i-hate-spam.com> wrote in message
news:u$******** *****@TK2MSFTNG P09.phx.gbl...
Hi,

If my ProjectTable contains a lot of rows, each time I call the
following code, will all the rows be fetched? Or only those 5 records
for that page are fetched only?

/* -- code start -- */
OdbcConnection connection = new OdbcConnection( "DSN=Whatever") ;
connection.Open ();
string query = "SELECT * FROM ProjectTable";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter (query, connection);
DataSet dataSet = new DataSet();
dataAdapter.Fil l(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource ();
pagedDataSrc.Da taSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.Al lowPaging = true;
pagedDataSrc.Pa geSize = 5;

setPageIndex();

MyRepeater.Data Source = pagedDataSrc;
MyRepeater.Data Bind();
/* -- code end -- */

Thanks,
Franz



Jan 3 '06 #4

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

Similar topics

7
4850
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As InternetExplorer But then I cant see when a user exit my objIExplorer and than an error will show up when I try to open a link in the IE window that does not exist... What can I do about this and way does it not work in win 98?
2
3432
by: Fresh Air Rider | last post by:
Hi There are plenty of examples on the internet of using the PagedDataSource in conjunction with a dataset to implement paging within the Repeater control. Does anyone know if this is possible with a Typed Dataset ? If so, a code snippet or link to relevant website would be much appreciated.
2
2223
by: darrel | last post by:
Or, rather, fill a dataset with a PagedDataSource object? I am using PagedData right now in this manner: Dim pagedData As New PagedDataSource() Sub doPaging() 'query the DB and return a copy of the Dataset as pagedData
1
1803
by: David Lozzi | last post by:
Howdy, Using .Net 2.0 I am using the PagedDataSource to page through my XML data source. My question and / or problem is is this opening the XML data source every time a user clicks through a page or is .Net smart enough to use the same dataset from the first request? I researched a bit and found how to cache a dataset, which would be great, and then specify a CacheDependency, but my problem with this is that the XML data source is...
14
4847
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it can be done using the designer but I intentionally don't want to use that. The one reason is that you cannot change the code generated by the designer. The other could be that you have more free hand and control to design your GUI. 2....
89
6041
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
1
7129
by: jazzart | last post by:
Hi there, I'm fairly new to programming with Asp.Net 2.0 so I'm finding myself regularly fumbling around in the dark a bit, so to speak. I'm currently using Visual Web Developer and have been following the www.asp.net data access tutorials to create a DAL and BLL to connect my web site (a simple real estate property search web site) to my database (Sql Express 2005).
1
1763
by: barryh | last post by:
I have an on-line catalogue that has a hierarchal category structure. I am using the PagedDataSource to wrap the business object along with the Repeater control to display the items in pages. The problem I am having is linking to an item that is not on the first page of a given category. What is the best approach to determining which page an item is on? Thanks
1
1863
by: Stimp | last post by:
In terms of performance/system resources/good practice, is it generally better to perform paging within an SQL query rather than paging a datasource that implements that query? In this particular instance, each row could have many bytes since I use a VARCHAR(max). I'm under the impression that SQL paging (where possible) is always preferable, but would be interested to hear pros/cons --
0
8601
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7716
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3043
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 we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.