burghboy
asked on
Extracting column names from a DataView
I found an answer here that uses the DataView.Table property to get the column names. This is valid if all of the columns are used in the DataView. However, I have DataView instances that do not always show all of the columns. Both the .Table property and the ToTable() method return a DataTable with ALL of the columns of the underlying table. Is there a way to extract the column names from the DataView itself so that I can only show those that pertain to the DataView? Is there some way to isolate that information?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Extract a row from the dataview, any.
this DataRow object has a DataTable property
Look at the components of this datatable
that is:
foreach (DataColumn col in yourview.Rows[0].DataTable
{
string name = col.Name
}