我为这个令人费解的标题道歉。
我有一个如下所示的 DataList
:
<asp:DataList ID="DataListFloor" runat="server" RepeatColumns="5" >
<ItemTemplate>
<div style='width:199px;height:166px;background-color: <%# Eval("background") %>'>
<div style="width: 199px; height: 22px; overflow: hidden;">
<div style="box-sizing: border-box; width:97px; float:left;">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
绑定(bind)到这个 DataList
的数据表是:
Name background background_mouseOver
----------------------------------------
Joe Yellow Orange
Mary white Beige
Jane Red Maroon
Carl gray Darkgray
div
的background-color
已经设置为background
列中的颜色。所以我知道该属性的 Eval
正在运行。
我的问题是:如何将 MouseOver
上 div
的 background-color
更改为 datatable< 中的值
列 background_mouseOver
。因此,例如,对于显示Joe 的数据列表项,背景颜色将为黄色。当我将光标移到该单元格上时,背景颜色将变为橙色。
请不要使用 jquery。
谢谢。
最佳答案
我最终以这种方式使用了 onMouseover
:
<div onMouseover="this.style.backgroundColor = '<%# Eval("background_mouseOver")%>'" style='background-color: <%# Eval("background") %>'>
</div>
关于javascript - 在 MouseOver 的 DataList ItemTemplate 内的 div 上使用 Eval?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37013297/