Multi stack
Multi stack

Reputation: 321

Access DataTable row

I have a DataTable and I access its rows using a foreach loop

foreach (DataRow row in table.Rows)
{
   userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]);
} 

but knowing that my DataTable contains only a single row, how can I access it without looping through it?

Upvotes: 0

Views: 207

Answers (1)

Huma Ali
Huma Ali

Reputation: 1809

You can use Index on Rows

DataRow row = table.Rows[0];
userId = Convert.ToInt32(row[BundleSchema.ParamUpdatedBy]);

Upvotes: 2

Related Questions