Highlighting the Selected Row GridView

最后都变了- 提交于 2019-12-13 12:36:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!