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
LVL 2
CipherISAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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]; 
GridView1.DataBind();

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lokesh B RDeveloperCommented:
Hi,

You can bind the DataTable as follows.

GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

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

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

There is no property called Table on DataSet.

It is DataSet.Tables

https://msdn.microsoft.com/en-us/library/system.data.dataset.tables%28v=vs.110%29.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.