Highlighting the Selected Row GridView
21,343
Solution 1
here is how i able to fix:
if ((e.Row.RowType == DataControlRowType.DataRow & ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit))) {
e.Row.BackColor = Drawing.Color.Yellow;
}
Solution 2
Did you try EditRowStyle
?
.EditRowStyle
{
background-color: Yellow;
}
<asp:GridView runat="server" CssClass="DataWebControlStyle">
<AlternatingRowStyle CssClass="AlternatingRowStyle" />
<RowStyle CssClass="RowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
</asp:GridView>
Solution 3
The EditRowStyle class is applied to the <tr>
not the <td>
. So if you did .SelectedRowStyle td
the css would be applied correctly.
This is what I use:
<EditRowStyle CssClass="selectedRowStyle" />
Then CSS
.selectedRowStyle td
{
background-color: green;
}
Comments
-
Nick Kahn almost 2 years
when the user click on Edit from the gridview i want to highlight the row and here is what i have done but no effect. what else i am missing?
.SelectedRowStyle { background-color: Yellow; } <asp:GridView runat="server" CssClass="DataWebControlStyle"> <AlternatingRowStyle CssClass="AlternatingRowStyle" /> <RowStyle CssClass="RowStyle" /> <HeaderStyle CssClass="HeaderStyle" /> <SelectedRowStyle CssClass="SelectedRowStyle" /> </asp:GridView>
-
Nick Kahn over 13 yearsi just tried with editrowstyle but does not highlight the row, may be because of postback?
-
Nick Kahn about 12 yearsRick, i am sorry for late response but i dont remember exactly where i have added.
-
Neil Knight over 11 yearsProbably because the
CssClass
doesn't relate to the CSS class