Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Going directly to a datatable row

Status
Not open for further replies.

dpanattoni

IS-IT--Management
Jan 29, 2002
76
US
I know I can directly access the first or last record in a dataset's datatable by the following:

// Go to first record in table.
DataTable dt = ds.Tables["Orders"];
DataRow dr = dt.Rows[0];

// Go to last record in table.
DataTable dt = ds.Tables["orders"];
DataRow dr = dt.Rows[(ds.Tables["Orders"].Rows.Count) - 1];

Is there somewhere that is stored in the datatable, which row is current? I want to create nextrow() and prevrow() functions, but would find it much easier if the rowindex is already being stored.

Thanks,
DP
 
The easiest way I can think of to do this is to use the wizard and generate yourself a data form. Then examine the code. You will see how they get the "position" with the navigation buttons it creates. Apply the code that the wizard uses in your own code.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top