Click here to Skip to main content
15,916,693 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi every one.


i am using datatable.am filtering the data and storing in datarow[]
DataRow[] dr = dt1.Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.
i am looping through the each row and displaying data.but i need to find the index of the datarow[].how to do that any one help me.here is my code..


C#
    DataTable dt = ds.Tables[0];
   DataRow[] dr = dt.Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.
  foreach (DataRow row in dr)
   {
//    here i want to find the index
  }
Posted
Updated 5-Feb-14 21:25pm
v2

Try:
C#
int index = dt.Rows.IndexOf(row);
 
Share this answer
 
Changing the loop to a for one would automatically produce the result:
C#
for (int index = 0; index < dt.Rows.Count; ++index)
{
  // nothing to do here, 'index' is already what you need.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900