How do I enumerate all columns in a DataViewRow?

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

This generates a compile error:

private void BuildFTPRec(DataRowView a)
{
foreach (DataColumn dc in a)
{
Console.WriteLine(r.ToString());
}
}

The error is as follows:

"foreach statement cannot operate on variables of type
'System.Data.DataRowView' because 'System.Data.DataRowView' does not contain
a definition for 'GetEnumerator', or it is inaccessible"
 
Bill,

The DataRowView allows you to reference the DataRow. From there,
reference the Table, and its Columns collection:

foreach (DataColumn col in MyDataRowView.Row.Table.Columns)

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 
Back
Top