gridview 删除按钮

 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        this.TextBox1.Text =this.GridView1.DataKeys[e.RowIndex].Value.ToString() ;
        string sql = "";
        sql = "delete NetBill where id ='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
        cmd = new SqlCommand(sql,Con);
        Con.Open();
        cmd.ExecuteNonQuery ();
        Con.Close();
        bind();

    }
    public void bind()
    {
        listBalanceBill.Clear();
        this.GetBillRecord(110019, DateTime.Now);
        this.GridView1.DataSource = listBalanceBill;
        GridView1.DataKeyNames = new string[] { "id" };
        this.GridView1.DataBind();
    }

你可能感兴趣的:(GridView)