问题
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>
回答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;
}
回答2:
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;
}
回答3:
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>
回答4:
May be this line of code help you:
.DataWebControlStyle tr:hover
{
background-color: Yellow;
}
<asp:GridView runat="server" CssClass="DataWebControlStyle">
<AlternatingRowStyle CssClass="AlternatingRowStyle" />
<RowStyle CssClass="RowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
</asp:GridView>
来源:https://stackoverflow.com/questions/4812203/highlighting-the-selected-row-gridview