table的用法:
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<table width="97%" height="25" border="0" align="center" cellpadding="0" cellspacing="0" style="border-bottom:1px #999999 dotted;">
<tr id="row" runat="server">
<td width="3%" align="center" class="cheng"> ·</td>
<td width="97%" class="hei12" align=left>
<a href="#" title="<%#Eval("titleName")%>" target="_blank">
<font color='#ff0000'><%#Eval("titleName")%></font>(<%#Eval("AddTime", "{0:MM/dd}")%>) </a></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((HtmlTableRow)e.Item.FindControl("row")).BgColor= "#FF0000";
}
}
ul的用法:
<ul class="ChengGong_List">
<asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<ItemTemplate>
<li runat="server" id="li">
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("P_BuyType") %>' />
昵称:<%# Eval("P_Author") %> 地区:<%# Eval("P_Address") %>li>
</ItemTemplate>
</asp:Repeater>
</ul>
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
HiddenField hid = e.Item.FindControl("HiddenField1") as HiddenField;
if (Convert.ToInt32(hid.Value) == 1)
((HtmlControl)e.Item.FindControl("li")).Style.Add("color","green");
else
((HtmlControl)e.Item.FindControl("li")).Style.Add("color", "blue");
}
}
- 本文标题: repeater 嵌套table和ul实现改变整行row或li的css字体颜色
- 文章分类:【.NET/Web】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.