27 February 2014

How To Filter Data In DataSet Using C#

 protected void Button1_Click(object sender, EventArgs e)
    {
        DataSet ds = getdata();
        //Filtering Data (Showing record where salary is >20000 and <50000
        DataView dv = ds.Tables[0].DefaultView;
        //RowFilter is used to filter data in dataview
        dv.RowFilter = "esal>=20000 and esal<=50000";// 'and' operator can be used for multipal conditions
        //Sorting Record in Descending order
        dv.Sort = "esal desc";//Sort property is used to data in dataview
        GridView1.DataSource = dv;
        GridView1.DataBind();
    }

No comments:

Post a Comment