user968441 user968441 - 2 months ago 19x
ASP.NET (C#) Question

How to remove row from gridview on row command event?

I am trying to remove row from gridview by click on ImageButton which is placed inside gridview. I am getting row index but dont know how to remove. My gridview binds from session and i dont want to rebind gridview.

Here is my code:

protected void GVDetail_RowCommand(object sender, GridViewCommandEventArgs e)
if (e.CommandName.Equals("Remove"))
List<Class1> list = (List<Class1>)Session["value1"];
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gridRow = gvDetail.Rows[index];// (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);


If anyone have any idea about this than please help me..


Use the gridview deleterow method.

void GVDetail_RowCommand_RowCommand(Object sender, GridViewCommandEventArgs e)
     var id = Int32.Parse(e.CommandArgument);