kvnsdr
asked on
C# ASP.NET Winforms DataGrid DataSet Foreach?
The following code fills a listbox very well, however I would like to recieve the same result using a datagrid for both asp and winforms apps.
foreach(DataRow dataRow in dataSet1.Tables["resultDat a"].Rows)
{
listBox1.Items.Add(dataRow ["ArticleN umber"].To String()); //Displays results from SQL statement
}
foreach(DataRow dataRow in dataSet1.Tables["resultDat
{
listBox1.Items.Add(dataRow
}
You fill the DataGrid directlly
Create a DataTable and fill it withyour data, then Bind the dataTable to your DataGrid
Create a DataTable and fill it withyour data, then Bind the dataTable to your DataGrid
ASKER
Well I'm attempting to replace the "listbox1" in this code with a "DataSet".
foreach(DataRow dataRow in dataSet1.Tables["resultDat a"].Rows)
{
listBox1.Items.Add(dataRow ["ArticleN umber"].To String()); //Displays results from SQL statement
}
Q. Is there anyway a DataReader could work to quickly load a DataGrid in place of a DataSet?
foreach(DataRow dataRow in dataSet1.Tables["resultDat
{
listBox1.Items.Add(dataRow
}
Q. Is there anyway a DataReader could work to quickly load a DataGrid in place of a DataSet?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You want to add rows to a datagrid or wat? pls. Clarify.
Regards,
Chinmay