·
repeater使用分隔符
Code
<asp:repeater id="HotTB" Runat="server">
<ItemTemplate>
·
<asp:HyperLink ID="lnkTitle2" Runat="server"></asp:HyperLink>
<br>
</ItemTemplate>
<SeparatorTemplate>
<asp:Image ID="ee" Runat="server" Visible="False"></asp:Image>
</SeparatorTemplate>
</asp:repeater>
<asp:repeater id="HotTB" Runat="server">
<ItemTemplate>
·
<asp:HyperLink ID="lnkTitle2" Runat="server"></asp:HyperLink>
<br>
</ItemTemplate>
<SeparatorTemplate>
<asp:Image ID="ee" Runat="server" Visible="False"></asp:Image>
</SeparatorTemplate>
</asp:repeater>
后台代码:
Code
private void HotZT_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
{
Components.Entity.EBooks eb = (Components.Entity.EBooks)e.Item.DataItem;
try
{
HyperLink hl = e.Item.FindControl("lnkTitle1") as HyperLink;
hl.Text = Formater.Intercept(eb.Title,40);
hl.NavigateUrl = eb.Url;
hl.Target = "_blank";
hl.ToolTip =eb.Title;
}
catch(System.Exception e1){}
}
if(e.Item.ItemType == ListItemType.Separator)
{
if(Convert.ToInt32(e.Item.ItemIndex+1) % 4 == 0)
{
System.Web.UI.WebControls.Image ee = e.Item.FindControl("ee") as System.Web.UI.WebControls.Image;
ee.Visible = true;
ee.ImageUrl = "/mall/images/11.gif";
}
}
}
private void HotZT_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
{
Components.Entity.EBooks eb = (Components.Entity.EBooks)e.Item.DataItem;
try
{
HyperLink hl = e.Item.FindControl("lnkTitle1") as HyperLink;
hl.Text = Formater.Intercept(eb.Title,40);
hl.NavigateUrl = eb.Url;
hl.Target = "_blank";
hl.ToolTip =eb.Title;
}
catch(System.Exception e1){}
}
if(e.Item.ItemType == ListItemType.Separator)
{
if(Convert.ToInt32(e.Item.ItemIndex+1) % 4 == 0)
{
System.Web.UI.WebControls.Image ee = e.Item.FindControl("ee") as System.Web.UI.WebControls.Image;
ee.Visible = true;
ee.ImageUrl = "/mall/images/11.gif";
}
}
}