|
-
January 7th, 2009, 10:00 AM
#1
DataRow in a DataTable...Keeping track of row index.
Hi all,
I have a DataTable and I need to keep track of the current row index, I was not able to find any property of the datatable that does this.....
the only way i can see is to use a static index variable to do so....I was wondering if you guys know of any other better way to do this...
Thanks.
-
January 7th, 2009, 10:23 AM
#2
Re: DataRow in a DataTable...Keeping track of row index.
if you use DataGrid for representing data then handle RowEnter event of the datagrid:
Code:
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
label1.Text = e.RowIndex.ToString();
}
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
January 7th, 2009, 10:38 AM
#3
Re: DataRow in a DataTable...Keeping track of row index.
I cannot make use of an asp.net control here....?
DataTable is the data structure that is being used...
-
January 7th, 2009, 11:11 AM
#4
Re: DataRow in a DataTable...Keeping track of row index.
GridView can be used in win app and it differs somewhat with the GridView used in ASP.NET but their name are similar and they have common finctionality.
you should tell me how you change index of the Rows Collection. do you bind your datatable to a control like listbox, dropdownlist, gridview etc.
or itterate through the Rows in a Loop....if you use loop so the current index is the varible you use for control loop.
Code:
for (int i=0; i< dt.Rows.Count; ++i)
{
DoSomthing(); // Pseudo Method
ShowCurrentRow(i); // Pseudo Method
}
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|