Reputation: 38641
The function return DataRow
, and I want to get the columns header name? How to get it? I am programming in C#.
This is the code:
DataRow[] teDR=null;
DataRow[] DR = BizManyRecQuery.LoadForm.ManyRecQuery("f225839e-313a-488f-be47-55340ea46e34","prjProcessId",teDR);
if(DR!=null)
{
//get the columns header name
}
Upvotes: 1
Views: 97
Reputation: 106
Following should work
foreach (DataColumn c in DR[0].Table.Columns)
{
MessageBox.Show(c.ColumnName);
}
Upvotes: 1
Reputation: 81610
The DataRow class has a reference to the Table that it belongs to:
DR[0].Table.Columns[# or name]
Upvotes: 1
Reputation: 63317
The columns header name can be achieved only from DataTable.Columns
, so you can try this:
if(DR!=null&&DR.Any()) {
var headerNames = DR[0].Table.Columns.Cast<DataColumn>()
.Select(col=>col.ColumnName).ToList();
//remove ToList() if you want.
}
Upvotes: 2