In ASP., a dataset can contain more than one data table, and this instance is implemented by merging two data tables into a single dataset that contains all the tables in the original two datasets.
Key Technologies:the Merge method of a dataset allows you to merge the contents of another dataset, table collection, or row array into the current data set. The table's primary key, table name, constraints, and so on, all affect the effect of the merged dataset. The merge method is primarily used to merge the specified dataset and its schema into the current datasetpublic void Merge (DataSet DataSet);
code Example:
protected voidPage_Load (Objectsender, EventArgs e) {DataSet Dssource=NewDataSet ();//Create a source datasetDataSet Dstarget =NewDataSet ();//Create a target dataset stringConstr = configurationmanager.connectionstrings["Constr"]. ToString (); using(SqlConnection con =NewSqlConnection (CONSTR))//Create a data connection { //Creating a data adapterSqlDataAdapter SDA =NewSqlDataAdapter ("SELECT * from Dictionarytype", con); Sda. Fill (Dssource,"Dictionarytype");//to add a dictionary class to a source datasetSDA =NewSqlDataAdapter ("SELECT * from Dictionaryitem", con); Sda. Fill (Dstarget,"Dictionaryitem");//to add a dictionary value to a target dataset} dstarget.merge (Dssource); //to merge the Dictionarytype table of the source dataset into the target data setGridview1.datasource = dstarget.tables["Dictionarytype"]; Gridview1.databind (); }
dataset--merge, merging data content from two datasets