Link to home
Start Free TrialLog in
Avatar of sgidman
sgidman

asked on

c# dataview as a binding source

I have a common DataTable that i vish to display in various different ways in different datagridviews. It would appear that the best way is to use separate dataviews based on the datatable for each binding source for each DGV.

What I need to know is how to get the data table column names from the binding source

if the binding source is a datatable the following works

foreach (DataColumn Col in (cmbMCCB.Binding.DataSource as DataTable).Columns)

If the binding source is a dataview this does not work nor does

foreach (DataColumn Col in (cmbMCCB.Binding.DataSource as DataView)[0].Row.Table.Columns)

Any ideas
ASKER CERTIFIED SOLUTION
Avatar of rashmi_vaghela
rashmi_vaghela
Flag of India image

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
You can convert your dataTable into DataView like

DataTable1.DefaultView

Are you aksing this?
Avatar of sgidman
sgidman

ASKER

I solved it by using

foreach (DataColumn Col in ((System.Data.DataView)cmbMCCB.Binding.DataSource)[0].Row.Table.Columns)

Thanks for your help