62,266
社区成员
发帖
与我相关
我的任务
分享
<style type="text/css">
.oddtr_bg{background-color:#efefef;}/*偶数行*/
.eventr_bg{background-color:#ffffff;}/*奇数行*/
</style>
<script src="../js/JQuery1.5.1.js" type="text/jscript" language="javascript"></script>
<script type="text/jscript" language="javascript">
$(function(){
//隔行变色
var $tr_odd = $("tbody>tr:odd");
var $tr_even = $("tbody>tr:even");
var $trs = $("tbody tr");
$tr_odd.addClass("oddtr_bg"); /*偶数行添加样式 .oddtr_bg*/
$tr_even.addClass("eventr_bg"); /*奇数行添加样式 .eventr_bg*/
})
</script>
<table class="msg" border="1">
<thead>
<tr>
<th width="5%"></th>
<th width="15%">名字</th>
<th width="45%">公司</th>
<th width="20%">电话</th>
<th width="15%">编辑/删除</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptCards" runat="server">
<ItemTemplate>
<tr>
<td>绑定的数据</td>
<td>绑定的数据</td>
<td>绑定的数据</td>
<td>绑定的数据</td>
<td>绑定的数据</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
<style type="text/css">
.alt td {
background:#effafc;
}
</style>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr class=<%#(Container.ItemIndex%2==0)?"\"alt\"":"\"\""%>>
<td class="td1"><%# DataBinder.eval_r(Container.DataItem,"Rq","{0:yyyy年MM月dd日}") %></td>
<td class="td2"><%#eval_r("Out_Time")%></td>
<td class="td3"><%#eval_r("OperatorName")%></td>
<td class="td4"><%#eval_r("DepartmentName")%></td>
<td class="td5"><%#eval_r("Memo")%></td>
<td class="td6"><%#eval_r("In_Time")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr style='background-color: <%#(Container.ItemIndex%2==0)?"#fff":"#ccc"%>'>
<td>
<%# Eval("ID") %>
</td>
<td>
<%# Eval("Name") %>
</td>
<td>
<%# Eval("Address") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="RepArtList" runat="server" EnableViewState="false">
<ItemTemplate>
<tr class='<%#(Container.ItemIndex%2==0)?"TrGray":"TrWhite"%>'>
.....
或者判断:if(){}else{}
</tr>
</ItemTemplate>
</asp:Repeater>
<script language="javascript"><!--
function theObjTable(o,a,b,c){
var t=document.getElementById(o).getElementsByTagName("tr");
for(var i=0;i<t.length;i++){
t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
t[i].onclick=function(){
if(this.x!="1"){
}else{
this.x="0";
this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
}
}
t[i].onmouseover=function(){
if(this.x!="1")this.style.backgroundColor=c;
}
t[i].onmouseout=function(){
if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
}
}
}
--></script>
//senfe("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
不会,学习中
<asp:Repeater ID="RepArtList" runat="server" EnableViewState="false">
<ItemTemplate>
<tr class='<%#(Container.ItemIndex%2==0)?"TrGray":"TrWhite"%>'>
<td class="UclassArtTitle"><a href="#"><%# Eval("ArticleTitle")%></a></td>
<td><%# Eval("ViewCount")%></td>
<td><%# Eval("TjCount")%></td>
<td><%# Eval("UpCount")%> / <%# Eval("DownCount")%></td>
<td><%# Eval("ArtStatus")%></td>
<td><%# Convert.ToDateTime(Eval("CreateDate")).ToString("yyyy-MM-dd HH:mm")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>