Using GridViewRow DataBound Event Args
Posted on 2007-12-06
The following method is called when my gridview is databound. I want to make a button disappear on teh first and last records in the gridview. The code below only works for the first. The commented out line needs to be fixed to get it to work for the last.
How can I test to see if this is the last row being added to the gridview?
protected void gvSections_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
ImageButton up = (ImageButton)e.Row.FindControl("btMoveUp");
ImageButton down = (ImageButton)e.Row.FindControl("btMoveDown");
up.Visible = true;
down.Visible = true;
if (e.Row.RowIndex == 0) up.Visible = false;
//else if (e.Row.RowIndex > 3) down.Visible = false;