Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2762
  • Last Modified:

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

0
zell71
Asked:
zell71
  • 2
  • 2
1 Solution
 
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
 
zell71Author 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:
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now