点滴积累,融会贯通

-----喜欢一切有兴趣的东西

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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();
}

posted on 2006-02-10 11:16  小寒  阅读(625)  评论(1编辑  收藏  举报