Reputation: 9071
I have
xmlDoc.DataSet.Tables["<tablename>"].Columns
I want to loop through those columns via DataColumn
, for say this xmlDoc
has 10 entries and 5 are null, then the loop should happen for the non-null entries only.
Any thoughts?
Upvotes: 0
Views: 177
Reputation: 88
for (int i = 0; i < ds.Tables[0].Columns.Count; i++ )
{
DataColumn col = ds.Tables[0].Columns[i] != null ? ds.Tables[0].Columns[i] : "<some default value>";
if (col != "<some default value>")
// do something
}
Upvotes: 0
Reputation: 351668
How about this:
foreach (DataColumn column in xmlDoc.DataSet.Tables[""].Columns)
{
if (column != null)
{
// your code here
}
}
Upvotes: 2