Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

c# dataview as a binding source

Posted on 2010-08-26
3
1,681 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

856 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