我用GridView1绑定 DATATABEL(从数据库中获取数据)
我查询出来的数据如何在页面GridView1中点击删除按钮将GridView1中当前行数据给删除。
并且加载被查询出来的删除的DATATABEL的数据 或其他办法有吗??在线等等谢谢

解决方案 »

  1.   

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string sql = "delete from table where id=" + GridView1.DataKeys[e.RowIndex].Value;
            Classes cl = new Classes();
            if (!cl.InsertData(sql))
            {
                Response.Write("<script>alert('删除失败!')</script>");
            }
            bind();
        }
        private void bind()
        {
            OleDbConnection con = cl.CreateCon();
            OleDbDataAdapter oda = new OleDbDataAdapter("select * from product ", con);
            DataSet ds = new DataSet();
            oda.Fill(ds);
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = ds.Tables[0].DefaultView;
            GridView1.DataSource = ps;
            GridView1.DataKeyNames = new string[] { "id" };
            GridView1.DataBind();    }