473,699 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paging through a portion of a table in a DataGrid

Hi folks,

I am trying to page through a portion of the data in a table and therefore I
think I need to use Custom Paging.

.... but, I am wondering if I can pass a dataset that was obtained through a
function that returns a dataset that is a portion of a table. Apparently I
cannot do this as I keep getting the CurrentPageInde x must be or = 0 and <
PageCount error.

I guess I do not fully understand Custom Paging yet, so I will do some
reading on it but it seems that my method should work. My only thought is
that the PageCount is based on ALL of the records in a table and not just the
subset of records returned from my function. Also, I have found that
PageCount is readonly.

Here is the code I am using:

Function GetRecords(ByVa l record As Integer) As System.Data.Dat aSet

Dim connectionStrin g As String = "Provider=Micro soft.Jet.OLEDB. 4.0; Ole
DB Services=-4; Data Source=C:\path\ accessfile.mdb"
Dim dbConnection As System.Data.IDb Connection = New
System.Data.Ole Db.OleDbConnect ion(connectionS tring)

Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @anotherrecord) "
Dim dbCommand As System.Data.IDb Command = New Data.OleDb.OleD bCommand
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection

Dim dbParam_record As System.Data.IDa taParameter = New
System.Data.Ole Db.OleDbParamet er
dbParam_record. ParameterName = "@record"
dbParam_record. Value = record
dbParam_record. DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_record)

Dim dataAdapter As System.Data.IDb DataAdapter = New
System.Data.Ole Db.OleDbDataAda pter
dataAdapter.Sel ectCommand = dbCommand
Dim dataSet As System.Data.Dat aSet = New
System.Data.Dat aSet
dataAdapter.Fil l(dataSet)

Return dataSet
End Function
Sub BindData(sortEx pr as String)

Dim dataSet As DataSet = New DataSet()

dataSet = GetRecord(recor dID)

'Finally, specify the DataSource and call DataBind()
DataGrid1.DataS ource = dataset
DataGrid1.DataB ind()

End Sub

Any feedback is appreciated.
- Glenn
Aug 2 '06 #1
1 1261
Paging in Dataset assumes that the dataset contains complete set of data.

-Augustin

"glenn" wrote:
Hi folks,

I am trying to page through a portion of the data in a table and therefore I
think I need to use Custom Paging.

... but, I am wondering if I can pass a dataset that was obtained through a
function that returns a dataset that is a portion of a table. Apparently I
cannot do this as I keep getting the CurrentPageInde x must be or = 0 and <
PageCount error.

I guess I do not fully understand Custom Paging yet, so I will do some
reading on it but it seems that my method should work. My only thought is
that the PageCount is based on ALL of the records in a table and not just the
subset of records returned from my function. Also, I have found that
PageCount is readonly.

Here is the code I am using:

Function GetRecords(ByVa l record As Integer) As System.Data.Dat aSet

Dim connectionStrin g As String = "Provider=Micro soft.Jet.OLEDB. 4.0; Ole
DB Services=-4; Data Source=C:\path\ accessfile.mdb"
Dim dbConnection As System.Data.IDb Connection = New
System.Data.Ole Db.OleDbConnect ion(connectionS tring)

Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @anotherrecord) "
Dim dbCommand As System.Data.IDb Command = New Data.OleDb.OleD bCommand
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection

Dim dbParam_record As System.Data.IDa taParameter = New
System.Data.Ole Db.OleDbParamet er
dbParam_record. ParameterName = "@record"
dbParam_record. Value = record
dbParam_record. DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_record)

Dim dataAdapter As System.Data.IDb DataAdapter = New
System.Data.Ole Db.OleDbDataAda pter
dataAdapter.Sel ectCommand = dbCommand
Dim dataSet As System.Data.Dat aSet = New
System.Data.Dat aSet
dataAdapter.Fil l(dataSet)

Return dataSet
End Function
Sub BindData(sortEx pr as String)

Dim dataSet As DataSet = New DataSet()

dataSet = GetRecord(recor dID)

'Finally, specify the DataSource and call DataBind()
DataGrid1.DataS ource = dataset
DataGrid1.DataB ind()

End Sub

Any feedback is appreciated.
- Glenn
Aug 2 '06 #2

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

Similar topics

0
1233
by: Paul Perot | last post by:
Hi All: I am populating a Data Table with File/Folder information from my drive... I am then binding this data table to a DataGrid. Due to the size of the DataGrid data, I use the built in paging. All of this seems to work just fine. In certain circumstances I need to programically change one of the data column values from true to false or from false to true... To do this, I read in each datagriditem in the datagrid.items collection...
2
2236
by: Max | last post by:
Is it possible or more effecient to use a stored procedure to populate a datagrid when using datagrid or custom paging? Is it (ADO.NET?) pulling the entire table into the dataset or is it just pulling the page as defined by the page size? I'm assuming that if I use a stored procedure with a datagrid, I won't be able to use the datagrid's paging anyway, and would have to create my own code in the stored procedure to return each page of...
1
2315
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has to be scrolled down completely to see the page number links. The page number should always be visible outside the scroll bar. Basically I want to create the paging links dynamically and on click of this it should fire PageIndexChanged event.
2
2579
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has to be scrolled down completely to see the page number links. The page number should always be visible outside the scroll bar. Basically I want to create the paging links dynamically and on click of this it should fire PageIndexChanged event.
2
1374
by: George Durzi | last post by:
Is there a way to implement datagrid paging without using javascript on the client-side?
6
1813
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP fills the temp table again and returns rows 10-19. The temp table is dropped after each call to the SP, so it has to be created and filled every time the user changes page in the datagrid. My question is this: Would it be more efficient to...
2
2218
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
2
1860
by: Axel Dahmen | last post by:
Hi, I'm using a DataGrid control to show a table's content with paging. For navigation through the pages I'm using the DataGrid's intrinsic navigation section. My problem: The DataGrid navigation links use JavaScript to jump between pages. I want them to use standard hyperlinks providing the page number in some URL parameter so that I can copy the hyperlink elsewhere.
2
1933
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a particular order (like ProductID, Name, Description, Quantity etc.) are displayed in one DataGrid where as the personal details of the buyer corresponding to this order (like Name, E-Mail, Shipping & Billing Address etc.) are displayed in another...
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
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...
1
8914
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7750
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
6534
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
4376
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
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
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.