我尝试过一些东西,包括SelectedItemStyle和内联CSS。这是我现在拥有的:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.hoverTable tr:hover {
background-color: wheat;
}
.hoverTable tr:current {
background-color: aquamarine;
}
.SelectedTable {
background-color: aquamarine;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="divGrid" style='width:920px; height:230px; overflow:auto'>
<asp:DataGrid ID="DataGrid_ClaimSearch" runat="server"
AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false"
CssClass="hoverTable" OnSelectedIndexChanged="OnSelectedIndexChanged"
OnCancelCommand="DataGrid_ClaimSearch_CancelCommand"
OnUpdateCommand="DataGrid_ClaimSearch_UpdateCommand"
OnEditCommand="DataGrid_ClaimSearch_EditCommand">
<AlternatingItemStyle Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<EditItemStyle BackColor="#999999" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<PagerStyle BackColor="#5D7B9D" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<SelectedItemStyle BackColor="Teal" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" CancelText="Cancel"
EditText="Select" UpdateText="Update"></asp:EditCommandColumn>
<asp:BoundColumn HeaderText="Status" DataField="Status" />
<asp:BoundColumn HeaderText="LPI Review Date" DataField="Status_Date" />
<asp:BoundColumn HeaderText="LPI State" DataField="LPI_STATE" />
<asp:BoundColumn HeaderText="Paid Date" DataField="Claim_Paid_Date" />
<asp:BoundColumn HeaderText="Paid Amount" DataField="Claim_Paid_Amount" />
<asp:BoundColumn HeaderText="LPI Amount" DataField="Total_LPI_Amount" />
<asp:BoundColumn HeaderText="LPI_ID" DataField="LPI_ID" ItemStyle-Width="0px" />
</Columns>
</asp:DataGrid>
<asp:Label ID="lblEmpty" runat="server" Visible="false" Style="font-weight:bold; font-size:large;"></asp:Label>
</div>
</asp:Content>
标题中的CSS不会更改所选行。 GridView中的SelectedItemStyle标记不会更改所选的行。将RowStyle-CssClass添加到GridView也没有帮助。 tr:hover CSS工作正常。在使用EditCommandColumn按钮时,我找不到任何更改行所选样式的示例。任何帮助表示赞赏。
BTW,这是使用C#构建的Intranet网页的一部分,如果这有所不同。
答案 0 :(得分:2)
无论如何,为了后人的缘故,这就是答案。
在DataGrid_ClaimSearch_EditCommand
空格中,我添加了这一行:
e.Item.BackColor = Color.FromName("#E56E94");
这很容易!