Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to delete Specific row on condition
C#
     protected void ItemDataBound(object sender, GridViewRowEventArgs e)
{
  if (Childs < 5)
 {
                     
                       
grdname.Parent.Controls.RemoveAt(e.Row.RowIndex);

 }
}
Posted
Comments
solanki.net 12-Mar-13 4:34am    
can u explain on which event u want to delete row ?

Try Gridview RowCommand method for deleting a row
C#
void gridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Remove")
{
     var childs= Int32.Parse(e.CommandArgument);
if(childs<5)
     gridView.DeleteRow(id);

 }
}


Go through this link more about RowCommand Event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx[^]
Hope this helps
 
Share this answer
 
v2
C#
e.row.visible=false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900