Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to join two datatable datas into one datatable to show in one gridview in asp.net

how to join two datatable datas into one datatable to show in one gridview

i.e in 1 datatable i have username and pwd and in another datatable i have that user details. how to show all these in one datatable to get those values display in gridview(asp.net)

any idea????

like image 715
Innova Avatar asked May 24 '10 06:05

Innova


2 Answers

on=new SqlConnection("Data Source=MCN101; Initial Catalog=MergeTable; Uid=sa; pwd=");
da = new SqlDataAdapter("Select * from Table1", con);
da.Fill(ds1, "Record");
da = new SqlDataAdapter("select * from Table2", con);
da.Fill(ds2, "Record");
ds1.Merge(ds2);
GridAllRecord.DataSource = ds1;
GridAllRecord.DataBind();
like image 164
Rama Avatar answered Oct 08 '22 22:10

Rama


You can merge two datatable, here is the sample for that. http://msdn.microsoft.com/en-us/library/system.data.datatable.merge.aspx

like image 38
Thurein Avatar answered Oct 08 '22 23:10

Thurein