Home > DeveloperSection > Forums > GridView is hiding after Row Deleting Event
Mark Devid
Mark Devid

Total Post:101

Points:707
Posted on    March-06-2014 10:59 PM

 C# C# 
Ratings:


 1 Reply(s)
 808  View(s)
Rate this:

I am using GridView Row command Event for deleting row from Gridview, I have added RowDeleting Event of gridview, but after deleting the GridView is getting hide. Below is my code

 protected void Page_Load(object sender, EventArgs e)

        {

       if (!Page.IsPostBack){

LoadData()//Here I am databinding the Grid

}

}

private void LoadData()

{

var data=MyClass.GetRecords();//it returns  DataTable

dg.DataSource=data;

dg.DataBind();

}

protected void dg_RowCommand(Object sender, GridViewCommandEventArgs e)

{

    if(e.CommandName =="del")

    {

        //Delete Records

        dg.DataBind();

    }

}

public void dg_RowDeleting(Object sender, GridViewDeleteEventArgs e)

{

    dg.DataBind();

}



Pravesh Singh

Total Post:411

Points:2881
Posted on    March-06-2014 11:15 PM

Hi Mark,

My guess is you are missing DataSource after deleting the rows.

Try this

protected void dg_RowCommand(Object sender, GridViewCommandEventArgs e)

{

    if(e.CommandName =="del")

    {

        //Delete Records

       LoadData();

    }

}

public void dg_RowDeleting(Object sender, GridViewDeleteEventArgs e)

{

    LoadData();

}


Don't want to miss updates? Please click the below button!

Follow MindStick