62,040
社区成员
发帖
与我相关
我的任务
分享
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex < 10) //索引从0开始。
{
e.Row.BackColor = Color.Red; //Color.FromName("#FF0000");
}
}
HtmlTableRow rptItem = e.Item.FindControl("rptItem") as HtmlTableRow;
rptItem .Style.Add("background-color", "#e4e3e3");
<ItemTemplate> <div id="rptItem" runat="server">
<tr >
<td >
<%-- 第
<%# (当前页-1)*总页数+ Container.ItemIndex + 1%>
名--%>
第<asp:Label ID="Ranking" runat="server" Text="<%# (GetData() - 1) * GetDataall() + Container.ItemIndex + 1%>"></asp:Label>
名
</td>
<td >
<a href="SheShow.aspx?id=<%#Eval("id")%>">
<%#Eval("StudentName")%> </a>
</td>
<td >
<%#Eval("danwei")%>
</td>
<td >
<%#Eval("score")%>
</td>
<td >
<%#Eval("toupiao")%>
</td>
</tr></div>
protected void commentlist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HtmlGenericControl rptItem = e.Item.FindControl("rptItem") as HtmlGenericControl;
if (e.Item.ItemIndex < 10)
{
//rptItem.Attributes.Add("class", "前十行样式"); // 设置前十行样式
rptItem.Style.Add("background-color", "#e4e3e3"); // 背景色也可
}
else
{
//rptItem.Attributes.Add("class", "后面样式"); // 设置前十行样式
rptItem.Style.Add("background-color", "#fff"); // 背景色也可
}
}
<ItemTemplate>
<div id="rptItem" runat="server">... ...</div>
</ItemTemplate>
HtmlGenericControl rptItem= e.Item.FindControl("rptItem") as HtmlGenericControl;
if(e.Item.ItemIndex < 10)
{
rptItem.Attributes.Add("class", "前十行样式"); // 设置前十行样式
// rptItem.Style.Add("background-color", "#e4e3e3"); // 背景色也可
}
else
{
rptItem.Attributes.Add("class", "后面样式"); // 设置前十行样式
// rptItem.Style.Add("background-color", "#fff"); // 背景色也可
}