populate a dataset from a list

hi guys,
i have a list with a number of strings..
i wish to display those values on on a datagridview.
what method shall i use?im struggling to pass the string list to a dataset.

thanks
// code i've got so far
                clsListClass myFileToSend;
                clsDataBase cls = new clsDataBase();
                myFileToSend = cls.GetData(No);                
 
                foreach (string myString in myFileToSend.Names)
                {                    
                    
                }

Open in new window

LVL 6
zell71Asked:
Who is Participating?
 
zell71Connect With a Mentor Author Commented:

clsListClass myFileToSend;
                clsDataBase cls = new clsDataBase();
                myFileToSend = cls.GetData(No);  
                
                // creating new dataset and datatable
                DataSet dsResults = new DataSet();
                DataTable dsTable = dsResults.Tables.Add();
                dsTable.Columns.Add("Purchase Order No", typeof(string));
 
                foreach (string myString in myFileToSend.Names)
                {   
                    // add data into custom created dataset
                    dsTable.Rows.Add(myPOHeaderID);
                }

Open in new window

0
 
Bob LearnedCommented:
You don't need to create a DataSet, in order to bind a list of objects to a DataGridView.  Your objects just need to have public properties which you can specify in the column's DataPropertyName.
0
 
Bob LearnedCommented:
Does that work, or is that what you were using that has problems?  Did you define columns for the DataGridView, and set the DataSource property to 'dsTable'?
0
 
zell71Author Commented:
I created a dataset with a datatable and passed my list values into that dataset.my question was to ask how I did but I found the answer
0
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.