[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1856
  • Last Modified:

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
0
sgidman
Asked:
sgidman
1 Solution
 
rashmi_vaghelaCommented:
0
 
Mohit VijayCommented:
You can convert your dataTable into DataView like

DataTable1.DefaultView

Are you aksing this?
0
 
sgidmanAuthor Commented:
I solved it by using

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

Thanks for your help
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now