Link to home
Start Free TrialLog in
Avatar of burghboy
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?
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

try with the following:
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.Columns)
{
        string name = col.Name
}
ASKER CERTIFIED SOLUTION
Avatar of burghboy
burghboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial