021. Merging of ASP. NET two dataset datasets

Source: Internet
Author: User

    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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.