Solved

c# dataview as a binding source

Posted on 2010-08-26
3
1,617 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
Comment Utility
0
 
LVL 8

Expert Comment

by:Mohit Vijay
Comment Utility
You can convert your dataTable into DataView like

DataTable1.DefaultView

Are you aksing this?
0
 

Author Comment

by:sgidman
Comment Utility
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now