Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have many DataTables in DataSet... I want to bind all the rows of DataTables from DataSet to gridview... Any idea for this... Thanks!!!
Posted

So you are saying that you want all the datatables' data into a single gridview.

Well for that

1. ensure that all the tables in the datatable have same schema, else its little troublesome and complicated.
2. have a temporary datatable and push all the datatables data into that.
3. bind the gridview with this temp datatable.
 
Share this answer
 
Comments
Siana0123 6-Jul-12 3:30am    
thx for yr ans...:)
hello

you can simply bind dataTable those you need like:-
gridView1.DataSource=datasetObj.Tables["rizwanTableName if it not work then use index "];
gridview1.Databind();
 
Share this answer
 
hello

you can simply bind dataTable those you need like:-
gridView1.DataSource=datasetObj.Tables["rizwanTableName if it not work then use index "];
gridview1.Databind();
 
Share this answer
 
DataSet Datasetname = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["MyConnectionString"],
"YourProcname",
Parameters);
// For First table
if (Datasetname .Tables[0].Rows.Count > 0)
{
gridview.DataSource = Datasetname ;
gridview.DataBind();

}
// For Second table
if (Datasetname .Tables[1].Rows.Count > 0)
{
gridview.DataSource = Datasetname ;
gridview.DataBind();

}
Column and column name should be same for all Tables
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900