更新时间:2023-01-06 20:54:18
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();
}
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.