asp:datalist 中使用ItemTemplate后,如何为每一行添加风格(如css、事件onmouseover)
使用itemtemplate后,最后自动生成了一个table,每个Itemtemplate生成一个行与列,但是怎么加风格呢?!
多谢 !
------解决方案--------------------友情UP
------解决方案--------------------直接加就可以啊
------解决方案-------------------- <asp:DataList id= "DataList1 " runat= "server ">
<ItemStyle CssClass= "aa " />
<ItemTemplate>
<%#Eval( "name ") %>
</ItemTemplate>
</asp:DataList>
------解决方案--------------------觉得用repeater更灵活
如:
<asp:Repeater ID= "torrentList " runat= "server ">
<HeaderTemplate>
<table width= "773 " border= "0 " cellpadding= "0 " cellspacing= "0 " bordercolor= "#FFFFFF ">
<tr>
<td bgcolor= "#FFFFFF ">
<table id= "torrentList " style= "width: 95%; border-collapse: collapse " cellspacing= "0 "
cellpadding= "5 " rules= "all " border= "1 ">
<tbody>
<tr align= "middle ">
<td background= "images/MZDBT_18.gif ">
发布时间 </td>
<td background= "images/MZDBT_18.gif ">
资源名称 </td>
<td background= "images/MZDBT_18.gif ">
版本更新 </td>
<td background= "images/MZDBT_18.gif ">
官方网站 </td>
<td background= "images/MZDBT_18.gif ">
类别 </td>
<td background= "images/MZDBT_18.gif ">
文件大小(MB) </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
///在这里就可以很方便的定义这些事件......
<tr onmouseover= "this.style.backgroundColor= '#fffeee ' " onclick= "ustbwuyi(this) " onmouseout= "this.style.backgroundColor= '#ffffff ' ">
<td width= "16% ">
<%# Eval( "Date ", "{0:yyyy-MM-dd HH:mm} " ) %>
</td>
<td width= "29% ">
<span title= ' <%# Eval( "name ") %> ' onmouseover= "this.style.color= '#ff9900 ' " onmouseout= "this.style.color= '#000000 ' "
onclick= "Add(this) " style= "text-decoration: underline; cursor: pointer; " id= ' <%# Eval( "id ")%> '>
<%# (Eval( "name ").ToString().Length> 22)?Eval( "name ").ToString().Substring(0,22):Eval( "name ") %>
</span>
<asp:Image ID= "show " runat= "server " Visible= ' <%# (Convert.ToDateTime(Eval( "Date ").ToString())> DateTime.Now.Date)?true:false %> '
ImageUrl= "~/images/091.gif " />
</td>
<td width= "22% " align= "center ">
<%# (Eval( "updateinformation ")%>