绑定后数据后设置div的class属性
<table border="0" cellspacing="0" cellpadding="0" width="96%"> <tbody> <tr> <td height="33" align="left"> <div class="bottomNewsTitle"> <ul> <asp:Repeater ID="rtitle" runat="server"> <ItemTemplate> <li class="ti tle_Off" id="titleT<%# Container.ItemIndex %>" onmouseover="PanShow('title',<%# Container.ItemIndex %>,3)"> <%#Eval("Nclass")%></li> </ItemTemplate> </asp:Repeater> </ul> </div> </td> </tr> </tbody> </table>运行生成后的html如下:<table border="0" cellspacing="0" cellpadding="0" width="96%"> <tbody> <tr> <td height="33" align="left"> <div class="bottomNewsTitle"> <ul> <li class="ti tle_Off" id="titleT0" onmouseover="PanShow('title',0,3)"> 综合考评</li> <li class="ti tle_Off" id="titleT1" onmouseover="PanShow('title',1,3)"> 中学教育</li> <li class="ti tle_Off" id="titleT2" onmouseover="PanShow('title',2,3)"> 小学教育</li> <li class="ti tle_Off" id="titleT3" onmouseover="PanShow('title',3,3)"> 幼儿教育</li> </ul> </div> </td> </tr> </tbody>
中学教育</li>
<li class="title_Off" id="titleT2" onmouseover="PanShow('title',2,3)">
小学教育</li>
<li class="title_Off" id="titleT3" onmouseover="PanShow('title',3,3)">
幼儿教育</li>
</ul>
[解决办法]
<li class='<%#Container.ItemIndex==0?"title_on":"title_Off"%>' id="titleT0" onmouseover="PanShow('title',0,3)">综合考评</li>