473,324 Members | 2,501 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,324 software developers and data experts.

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.Fill(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource();
pagedDataSrc.DataSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.AllowPaging = true;
pagedDataSrc.PageSize = 5;

setPageIndex();

MyRepeater.DataSource = pagedDataSrc;
MyRepeater.DataBind();
/* -- code end -- */

Thanks,
Franz
Jan 3 '06 #1
3 2886
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$*************@TK2MSFTNGP09.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.Fill(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource();
pagedDataSrc.DataSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.AllowPaging = true;
pagedDataSrc.PageSize = 5;

setPageIndex();

MyRepeater.DataSource = pagedDataSrc;
MyRepeater.DataBind();
/* -- 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.phx.gb l...
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$*************@TK2MSFTNGP09.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.Fill(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource();
pagedDataSrc.DataSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.AllowPaging = true;
pagedDataSrc.PageSize = 5;

setPageIndex();

MyRepeater.DataSource = pagedDataSrc;
MyRepeater.DataBind();
/* -- 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**************@TK2MSFTNGP11.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.phx.gb l...
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$*************@TK2MSFTNGP09.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.Fill(dataSet);

PagedDataSource pagedDataSrc = new PagedDataSource();
pagedDataSrc.DataSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.AllowPaging = true;
pagedDataSrc.PageSize = 5;

setPageIndex();

MyRepeater.DataSource = pagedDataSrc;
MyRepeater.DataBind();
/* -- 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
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...
2
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...
2
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...
1
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...
14
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...
89
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...
1
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...
1
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...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.