Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataRow : Where is the Count ?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00735641
Message ID:
00735650
Views:
8
>I am trying to itirate with a for in a DataRow but i am hitting a road block. ther is no Count property on the DataRow !!
>
>DataSet ds = MyDataSetMethod();
>foreach ( DataRow dr in ds.Tables[0].Rows )
>{
>	for (int i ; i < dr.Count ; i++ )
>	//Do some stuff
>	;
>}
>
>
>What am i missing ?

Nothing,
Actually you are going to far!

You don't need a count. The datarow is like a record in a table so there is nothing to count or iterate. (Other than fields).
Your foreach is already taking you through all the rows in the table[0].
You can access the fields like this:
dr["MyField"].ToString() ;

If you wanted to use a for instead of a foreach you would get the record count (datarow count) from your table like this: ds.Tables[0].Rows.Count
and reference like this: ds.Tables[0].Rows[i]["MyField"].ToString() ;
Chris
Previous
Reply
Map
View

Click here to load this message in the networking platform