protected voidPage_Load (Objectsender, EventArgs e) {DataSet Dssource=NewDataSet ();//Create a source datasetDataTable dt = createdatatable ();//Create a local tableDSSOURCE.TABLES.ADD (DT);//to add the created local table to the source datasetDataSet CopyDataSet1= Dssource.copy ();//copy entire data set (contains data)//Copy only the portion of the table data in the source dataset that was changedDataSet CopyDataSet2 =dssource.getchanges (); //Copy only the portion of the table data row status in the source dataset to the Add StateDataSet CopyDataSet3 =dssource.getchanges (datarowstate.added); //Copy only the schema of the source datasetDataSet CopyDataSet4 =Dssource.clone (); //gets the specified data for the specified table in the source datasetdatarow[] CopyRows = dssource.tables[0]. Select ("productCode = ' 0001 '"); //import the obtained data array into the data set table of the copy-only schemaDataTable Tbsource = copydataset4.tables[0]; foreach(DataRow CopyrowinchcopyRows) {Tbsource.importrow (Copyrow); } Gridview1.datasource=Tbsource; Gridview1.databind (); } PrivateDataTable Createdatatable () {DataTable dt=NewDataTable (); Dt. Columns.Add ("ProductCode",typeof(string)); Dt. Columns.Add ("saledate",typeof(DateTime)); Dt. Columns.Add ("SaleAmount",typeof(Double)); DataRow Dr=dt. NewRow (); dr["ProductCode"] ="0001"; dr["saledate"] = Convert.todatetime ("2009-2-1"); dr["SaleAmount"] = +; Dt. Rows.Add (DR); Dr=dt. NewRow (); dr["ProductCode"] ="0001"; dr["saledate"] = Convert.todatetime ("2009-1-1"); dr["SaleAmount"] = -; Dt. Rows.Add (DR); Dr=dt. NewRow (); dr["ProductCode"] ="0002"; dr["saledate"] = Convert.todatetime ("2009-1-1"); dr["SaleAmount"] = the; Dt. Rows.Add (DR); returnDT; }
021. Merging of ASP. NET two dataset datasets