Multiple Views of Data

Multiple views of a DataTable can be created by using the DataView object, which contains properties and methods that allow for sorting and filtering of the data.

private void btnSubmit_Click(
        object sender, System.EventArgs e) {
        this.pnlDataGrids.Visible = true;
        DataSet ds = new DataSet();
        ds.ReadXmlSchema(Server.MapPath(
                 "XML/CustomersOrders.xsd"));
        ds.ReadXml(Server.MapPath("XML/CustomersOrders.xml"));
        DataView view = new DataView(ds.Tables["Orders"]);
        view.RowFilter = "ShippedDate > '" + 
                this.txtStartDate.Text + "'";
        view.Sort = "CustomerID";
        DG.DataSource = view;
        DG.DataBind();

        //Using the FindRows() method
        DataRowView[] rows = view.FindRows(
                this.txtCustomerID.Text);
        DG2.DataSource = rows;
        DG2.DataBind();
}