Solved

c# dataview as a binding source

Posted on 2010-08-26
3
1,662 Views
Last Modified: 2012-05-10
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
Comment
Question by:sgidman
3 Comments
 
LVL 7

Accepted Solution

by:
rashmi_vaghela earned 500 total points
ID: 33529454
0
 
LVL 8

Expert Comment

by:Mohit Vijay
ID: 33529500
You can convert your dataTable into DataView like

DataTable1.DefaultView

Are you aksing this?
0
 

Author Comment

by:sgidman
ID: 33529626
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question