I have a gridview with edit and delete buttons on each row.
I am trying to change the back color or the fore color of the row in the gridview on which the edit button is clicked.
I am using the Row Editing event .Below is my code, the row editing event is not getting fired when I click the edit button.
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
ClearBackColor();
GridView1.SelectedIndex = e.NewEditIndex;
GridView1.SelectedRow.BackColor = System.Drawing.Color.Red;
//GridViewRow row = GridView1.Rows[e.NewEditIndex];
//row.ForeColor = Color.DarkGreen;
}
What could be wrong? Please let me know.
Check http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx. You are probably missing CommandName=”Edit” on button, so RowEditing will never fire.