C# ASP.NET数据列表-鼠标悬停时行背景颜色更改
我试图在大多数情况下改变行背景颜色,但我无法使其工作。我不确定我使用的C# ASP.NET数据列表-鼠标悬停时行背景颜色更改,c#,asp.net,webforms,C#,Asp.net,Webforms,我试图在大多数情况下改变行背景颜色,但我无法使其工作。我不确定我使用的OnItemDataBound是否正确,或者我的codebehind是否不正确 请帮忙。谢谢 <asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyListPartialMatch" runat="server" Width="80%" DataKeyField="Company1Word" UseAccessibleHe
OnItemDataBound
是否正确,或者我的codebehind是否不正确
请帮忙。谢谢
<asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyListPartialMatch" runat="server" Width="80%" DataKeyField="Company1Word"
UseAccessibleHeader="true"
CssClass="books"
HeaderStyle-CssClass="header"
ItemStyle-CssClass="item"
AlternatingItemStyle-CssClass="alternating"
GridLines="Both"
CellPadding="0"
CellSpacing="0" BorderColor="Black"
ItemStyle-BorderColor="Black" BorderWidth="0"
HorizontalAlign="Center"
RepeatDirection="Vertical"
OnItemDataBound="DataList1_ItemDataBound"
>
<HeaderTemplate>
</HeaderTemplate>
<ItemStyle BorderColor="black" Font-Size="Medium" />
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 50px; border-right:1px solid black; border-spacing:0; text-align:center; ">
<asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" Text="+" CommandArgument='<%#Container.ItemIndex%>'
OnCommand="LinkButton1_Command"
Font-Underline="false"
Height="25"
Font-Bold="true"
></asp:LinkButton>
</td>
<td style="width: 50px; border-right:1px solid black; border-spacing:0;"><%#Eval("Row")%></td>
<td style="width: 800px"><asp:Literal ID="litFoo" runat="server" Text='<%#Eval("Company")%>' /> </td>
<td style="width: 600px; text-align:right;">
<asp:CheckBox id="check1" runat="server" />
</td>
<asp:Label ID="lblRow" Visible="False" runat="Server" Text='<%# DataBinder.Eval(Container.DataItem, "Row") %>' />
</tr>
</table>
<asp:Panel ID="pnlChildView" runat="server" style="padding-left:200px;">
<asp:DataList ID="childList" runat="server" Width="100%">
<ItemTemplate>
<table class="table1" border="1">
<tr>
<td style="width: 800px; border-right:0px solid black; border-spacing:0;">• <%#Eval("CompanyName")%></td>
<td style="text-align:right; "><a href="/Apps/ERP/Other/CompanyInfo.asp?CompanyID=<%#Eval("CompanyID")%>" ><%#Eval("CompanyID")%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
尝试jQuery mouseover()方法
尝试jQuery mouseover()方法
我建议使用CSS。你可以在这里找到想法: 将CSS添加到顶部:
<style type="text/css">
.div_hover:hover { background-color: #000000; } <-- this is where you set your hover color
</style>
.div_hover:hover{背景色:#000000;}我建议使用CSS。你可以在这里找到想法:
将CSS添加到顶部:
<style type="text/css">
.div_hover:hover { background-color: #000000; } <-- this is where you set your hover color
</style>
.div_hover:hover{背景色:#000000;}能否显示您的模板?使用CSS,您可以更轻松地在模板级别应用CSS,甚至不需要为其编写代码。我已使用模板更新了代码。谢谢。你能展示一下你的模板吗?使用CSS,您可以更轻松地在模板级别应用CSS,甚至不需要为其编写代码。我已使用模板更新了代码。谢谢,谢谢你的回复。它仅更改链接按钮文本的颜色。我想突出显示整行。jQuery解决方案看起来也不错。我稍后会尝试。感谢您的回复。它仅更改链接按钮文本的颜色。我想突出显示整行。jQuery解决方案看起来也不错。我稍后会尝试。谢谢我按照您的建议尝试了,但是getter错误:Type'System.Web.UI.WebControls.DataList'没有名为'div'的公共属性。您必须将div放入项模板中。我正在更新我的答案给你看,我知道了。它起作用了。非常感谢(我放了)我按照您的建议尝试了很多,但是getter错误:Type“System.Web.UI.WebControls.DataList”没有名为“div”的公共属性。您必须将div放在项目模板中。我正在更新我的答案给你看,我知道了。它起作用了。非常感谢(我说)
<ItemTemplate>
<div class="div_hover">
[ItemTemplate stuff...]
</div>
</ItemTemplate>