private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
MySqlConnection conn = new MySqlConnection("User Id=root;Password=sa;Host=localhost;Database=mis;");
conn.Open();
MySqlDataAdapter da = new MySqlDataAdapter("select id, name, age from users ",conn);
DataSet ds =new DataSet();
da.Fill(ds,"users");
conn.Close();
DataGrid1.DataSource= ds;
DataGrid1.DataBind();
Session["a"] = ds;
}
}
private void Button3_Click(object sender, System.EventArgs e)
{
DataSet ds1 = new DataSet();
ds1 = ((DataSet)Session["a"]).Copy();
DataRow[] foundRows = ds1.Tables[0].Select("id>10");
foreach(DataRow r in foundRows)
{
ds1.Tables[0].Rows.Remove(r);
}
DataGrid1.DataSource= ds1;
DataGrid1.DataBind();
}
private void Button4_Click(object sender, System.EventArgs e)
{
DataSet ds1 = new DataSet();
ds1 = ((DataSet)Session["a"]).Copy();
DataRow[] foundRows = ds1.Tables[0].Select("id>2");
foreach(DataRow r in foundRows)
{
ds1.Tables[0].Rows.Remove(r);
}
DataGrid1.DataSource= ds1;
DataGrid1.DataBind();
}