如题,网页中repeater控件绑定两列,一列是图片名称。一列是显示图片控件。
想实现下面的效果:
根据图片名称显示图片。1、鼠标放到repeater显示的某一行时,自动显示右边的图片。我的repeater绑定代码是
<asp:Repeater ID="List" DataSourceID="sqlDsOrders" runat="server">
<HeaderTemplate>
<table class="grid" cellspacing="0" rules="all" border="1" style="border-collapse: collapse;">
<tr>
<th scope="col"> </th>
<th scope="col"> SiteNoName</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr onmouseover="this.style.backgroundColor='pink'" onmouseout="this.style.backgroundColor='FloralWhite' " class='<%# (Container.ItemIndex%2==0) ? "row" : "altrow" %>'>
<td class="rownum"><%# Container.ItemIndex+1 %></td>
<td style="width: 80px;"><%# Eval("SiteNoName")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
目前只能显示鼠标换行变色,无法实现上述效果。(领导要求用javascript取出值)。
想实现下面的效果:
根据图片名称显示图片。1、鼠标放到repeater显示的某一行时,自动显示右边的图片。我的repeater绑定代码是
<asp:Repeater ID="List" DataSourceID="sqlDsOrders" runat="server">
<HeaderTemplate>
<table class="grid" cellspacing="0" rules="all" border="1" style="border-collapse: collapse;">
<tr>
<th scope="col"> </th>
<th scope="col"> SiteNoName</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr onmouseover="this.style.backgroundColor='pink'" onmouseout="this.style.backgroundColor='FloralWhite' " class='<%# (Container.ItemIndex%2==0) ? "row" : "altrow" %>'>
<td class="rownum"><%# Container.ItemIndex+1 %></td>
<td style="width: 80px;"><%# Eval("SiteNoName")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
目前只能显示鼠标换行变色,无法实现上述效果。(领导要求用javascript取出值)。
function SwitchMenu(obj)
{
if(document.getElementById)
{
var el = document.getElementById(obj);
var ar = document.getElementsByTagName("table"); //DynamicDrive.com change
if(el.style.display != "block")
{ //DynamicDrive.com change
for (var i=0; i<ar.length; i++)
{
if(ar[i].className=="aaa"+obj)
{
ar[i].background="../images/menuup.gif";
}
}
el.style.display = "block"; //有权限可以打开
}
else
{
el.style.display = "none";
for (var i=0; i<ar.length; i++)
{
if(ar[i].className=="aaa"+obj)
{
ar[i].background="../images/menudown.gif";
}
}
}
}
}
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate> <table class="aaa<%# f %>" background="../images/menudown.gif" cellspacing="0" cellpadding="0" border="0" width="158" align="center">
<tr>
<td height="25" class="menutitle" onclick="SwitchMenu('<%# f %>')">
<strong><font color="30adf1"><%# Eval("powerName") %>
</font></strong></td>
</tr>
</table>
<table class="submenu" id="<%# f++ %>" border="0" cellpadding="0" cellspacing="0" background="../images/login_bg.gif" style="width:100%; height:auto">
<tr>
<td>
<asp:Repeater ID="Repeater2" DataSource='<%# Eval("pc") %>' runat="server">
<ItemTemplate>
<table cellspacing="1" cellpadding="1" border="0" width="158" align="center">
<tr>
<td >
<a href='../<%# Eval("powerUrl") %>'><%# Eval("powerName") %></a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>不知道对LZ有没有帮助