I have a DataSet
named DataSet1
. It contains an unknown number of tables and an unknown number of columns and rows in those tables. I would like to loop through each table and look at all of the data in each row for each column. I'm not sure how to code this. Any help would be appreciated!
foreach (DataTable table in dataSet.Tables) { foreach (DataRow row in table.Rows) { foreach (object item in row.ItemArray) { // read item } } }
Or, if you need the column info:
foreach (DataTable table in dataSet.Tables) { foreach (DataRow row in table.Rows) { foreach (DataColumn column in table.Columns) { object item = row[column]; // read column and item } } }
Just loop...
foreach(var table in DataSet1.Tables) { foreach(var col in table.Columns) { ... } foreach(var row in table.Rows) { object[] values = row.ItemArray; ... } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With