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

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 CurrentPageIndex 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(ByVal record As Integer) As System.Data.DataSet

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole
DB Services=-4; Data Source=C:\path\accessfile.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @anotherrecord)"
Dim dbCommand As System.Data.IDbCommand = New Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_record As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_record.ParameterName = "@record"
dbParam_record.Value = record
dbParam_record.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_record)

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New
System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function
Sub BindData(sortExpr as String)

Dim dataSet As DataSet = New DataSet()

dataSet = GetRecord(recordID)

'Finally, specify the DataSource and call DataBind()
DataGrid1.DataSource = dataset
DataGrid1.DataBind()

End Sub

Any feedback is appreciated.
- Glenn
Aug 2 '06 #1
1 1254
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 CurrentPageIndex 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(ByVal record As Integer) As System.Data.DataSet

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole
DB Services=-4; Data Source=C:\path\accessfile.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "SELECT [tablename].* FROM [tablename] WHERE
([discussion].[record] = @anotherrecord)"
Dim dbCommand As System.Data.IDbCommand = New Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_record As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_record.ParameterName = "@record"
dbParam_record.Value = record
dbParam_record.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_record)

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New
System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function
Sub BindData(sortExpr as String)

Dim dataSet As DataSet = New DataSet()

dataSet = GetRecord(recordID)

'Finally, specify the DataSource and call DataBind()
DataGrid1.DataSource = dataset
DataGrid1.DataBind()

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
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...
2
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...
1
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...
2
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...
2
by: George Durzi | last post by:
Is there a way to implement datagrid paging without using javascript on the client-side?
6
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...
2
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
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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
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,...

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.