Load data into datatable and set as itemsource

Posted on 2013-01-28
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 500 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 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