C# Convert DataTable to List and Add to GridView

I'm following code in this example -> http://dotnetawesome.blogspot.com/2014/01/how-to-group-columns-in-gridview-header-row-aspnet-programmer-friendly-way.html

On the website they have the below piece of code.
private void PopulateData()
2.            {
3.                using (MyDatabaseEntities dc = new MyDatabaseEntities())
4.                {
5.                    GridView1.DataSource = dc.SampleDatas.ToList();
6.                    GridView1.DataBind();
7.                }
8.                // Add Group Header
9.                SetGroupHeader();
10.            }

Open in new window

I am getting my data from a stored procedure and it is in a dataset.  How do I convert it to a List?  Do I have to convert it to a list to get the same result?

This is the video https://www.youtube.com/watch?v=LkFssh96VCE

Thank You
Who is Participating?
Fernando SotoRetiredCommented:
Try something like this, where DataSet_Instance_Name is your DataSet object and XXX is the table name as a string or the index in the collection of Tables.
GridView1.DataSource = DataSet_Instance_Name.Table[XXX]; 

Open in new window

Lokesh B RDeveloperCommented:

You can bind the DataTable as follows.

GridView1.DataSource = ds.Tables[0];

Imagine that your DataSet name is ds.
CipherISAuthor Commented:
Gridview.DataSource = dt;

I usually set it like that.  Thought I needed to convert it to a list for the other code.
Lokesh B RDeveloperCommented:

There is no property called Table on DataSet.

It is DataSet.Tables

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.