Changing EditRowStyle programmatically when Edit is clicked
Question
I have an ASP.NET(2.0 using C#) web app, in which I have a gridview. I have an Edit column in it, but I'm not using the regular Edit functionality. When Edit is clicked something else happens.
I wanted to know how to change the style of the row in which Edit was clicked in the GridView_RowEditing
function?
I have tried this:
protected void Grid_RowEditing(object sender, GridViewEditEventArgs e)
{
Grid.Rows[e.NewEditIndex].BorderStyle = BorderStyle.Groove;
//Do some Other things
}
When I click it, the other functionality works, but the style doesn't change. All I want to do is to change the style of the editRow so that I can tell which one it is.
Thank you.
Solution
As far as I understand, you can setup a particular style for SelectedItem in the GridView. Then when the edit button is clicked, you can do this -
grdView.SelectedIndex = e.NewEditIndex;
After doing this, the row in edit mode will get selected and the "SelectedItem" style will be applied to it.