Paging through a portion of a table in a DataGrid

G

Guest

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
 
G

Guest

Paging in Dataset assumes that the dataset contains complete set of data.

-Augustin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top