Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Load data into datatable and set as itemsource

Posted on 2013-01-28
Medium Priority
Last Modified: 2013-01-28
Hi guys,

I am trying to load data into a datatable and set the datatable as the itemsource of a datagrid.

My code below seems until it comes to setting the itemsource of the datagrid to t, the error message is....

Cannot implicitly convert type '' tp type 'system.collections.IEnumerable' and explicit conversion exists.

 private void LoadDataset()

            using (SqlConnection c = new SqlConnection("XXX"))

                using (SqlDataAdapter a = new SqlDataAdapter("select * from SQ_SysproHis_Step3", c))
                    DataTable t = new DataTable();

                    DataTableV2.ItemsSource = t;

Open in new window

Many Thanks,
Question by:deanlee17
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

Expert Comment

ID: 38826552
if DataTableV2 is your datagrid , you should use:

DataTableV2.datasource = t

Accepted Solution

esolve earned 2000 total points
ID: 38826562
DataGrid1.DataSource = ds; //where ds = dataset which contains your table
DataGrid1.DataMember = ds.Tables[0].TableName;

datagrid.ItemsSource = dataset.Tables[0].DefaultView;

So in your case if you're using silverlight I suppose you can bind to the

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

722 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