Click here to Skip to main content
15,909,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can display fileds between two tables in gridview by c#
Posted

void BindGrid()
{
SqlConnection myConnection = new SqlConnection(strConn);
DataSet DS1;
DataSet DS2;

//cmd1 &cmd2 are SqlCommand objects pre lang="c#">
pre>

SqlDataAdapter MyCommand;

MyCommand = new SqlDataAdapter(cmd1, MyConnection);

DS1 = new DataSet();
MyCommand.Fill(DS1, "MyTable");

MyCommand = new SqlDataAdapter(cmd2, MyConnection);
DS2 = new DataSet();

MyCommand.Fill(DS2, "MyTable");

// Note : The table in both DataSet ["MyTable"] must have same name  


ds1.merge(ds2);

MyDataGrid.DataSource = DS1.tables[0].DefaultView;
MyDataGrid.DataBind();
}
 
Share this answer
 
HI,

You can display filds between two tables in gridview
When u write Query to retrieve data from database to use join to merge data one or more table other wise if u don't have any common column on table to create view to using multiple table and show the view to gridview.
 
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