English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how to move from one record to next record in Dataset in asp.net like in loop. how to move to previous record? first record, last record, next record and previous record

2006-08-25 22:03:43 · 3 answers · asked by marium2kin 1 in Computers & Internet Programming & Design

3 answers

Dataset contains array of datatables and datatable contains array of datarows.
//So if you want to loop the rows in VB:

Dim i as integer
Dim ds as dataset
Dim dr as datarow
' put some codes to fill dataset

For i = 0 to ds.tables(0).rows.count -1
dr = ds.tables(0).rows(i)
'get values by dr.items("columnname")
Next

'get the first record
dr = ds.tables(0).rows(0)

'get last record
dr = ds.tables(0).rows ( ds.tables(0).rows.count -1)

2006-08-27 16:23:06 · answer #1 · answered by ei t 2 · 0 0

Hi,

DataSets are a collection of DataTables. Each DataTable is composed of DataRows which can be looped over.


//Example Source Code below
//ds is the variable for a filled data set

for (int i = 0; i< ds.tables[0].rows.count; i++)
{
DataRow dr = ds.tables[0].rows[i];

//You can do work with the Data Row (dr) here

}

The above code illustrates how to loop over rows and obviously you can hit the records in any order.


Previous Row:
If you want to hit the previous record, you merely need to know the index of the current row and subtract one.

First Row
The first row of a dataset always has the index of 0.

Last Row
The last row always has the index of rows.count - 1.


Hope this helps,

Leo

2006-08-26 15:41:08 · answer #2 · answered by Leo R 2 · 1 0

recordset.action

2006-08-26 05:05:58 · answer #3 · answered by gandalf 4 · 0 1

fedest.com, questions and answers