How to delete row in gridview using rowdeleting event?

前端 未结 16 1611

This is my .cs code :

protected void Gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
 Gridview1.DeleteRow(e.RowIndex);
 Gridvi         


        
16条回答
  •  一个人的身影
    2020-12-03 16:48

    Add the below line in Page load,

    ViewState["GetRecords"] = dt;
    

    then try this,

    protected void DeleteRows(object sender, GridViewDeleteEventArgs e)
    {
       dt = ViewState["GetRecords"] as DataTable;
       dt.Rows.RemoveAt(e.RowIndex);
        dt.AcceptChanges();
        ViewState["GetRecords"] = dt;
        BindData();
    }
    

    If you Still have any problem, send the code in BindData() method

提交回复
热议问题