我正在合并两个数据集,我希望重复的行只绑定一次,我该如何实现?
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
showRelatedcat();
DataSet ds = new DataSet();
DataSet ds_frd = new DataSet();
String frdQuery = my query
String newquery = my other query
String queryString = another one
try
{
// Connect to the database and run the query.
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter(newquery, connection);
SqlDataAdapter adapter1 = new SqlDataAdapter(frdQuery, connection);
// Fill the DataSet.
adapter1.Fill(ds_frd);
adapter.Fill(ds);
ds.Merge(ds_frd, true);
connection.Close();
}
catch (Exception ex)
{
// The connection failed. Display an error message.
//Message.Text = "Unable to connect to the database.";
}
RadGrid1.DataSource = ds.Tables[0].;
}
两个查询都有一些共同的行。