我在另一个中继器的 ItemTemplate 中有一个嵌套中继器。我向转发器添加了一个 OnItemDataBound 函数,但代码不执行
aspx
<asp:Repeater ID="rptComponents" runat="server" OnItemDataBound="rptComponents_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div class="row-fluid">
<div class="span2">
<asp:Repeater ID="rptComponentsImages" runat="server" OnItemDataBound="rptComponentsImages_ItemDataBound">
<HeaderTemplate>
<ul class="bxslider">
</HeaderTemplate>
<ItemTemplate>
<li>
<img src="<%# Eval("CKCI_File")%>" /></li>
</ItemTemplate>
<FooterTemplate>
<li runat="server" id="liNoData" visible="false">
<img src="http://placehold.it/132&text=No image" alt=""></li>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
<div class="">
<%# Eval("CKC_Title") %>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
编码
protected void rptComponents_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ClutchKitComponent rd = (ClutchKitComponent)e.Item.DataItem;
List<ClutchComponentImage> kitComponentImages = (List<ClutchComponentImage>)rd.images;
Repeater rt = (Repeater)e.Item.FindControl("rptComponentsImages");
rt.DataSource = kitComponentImages;
rt.DataBind();
}
}
protected void rptComponentsImages_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rt = (Repeater)sender;
if (rt.Items.Count < 1)
{
if (e.Item.ItemType == ListItemType.Footer)
{
e.Item.FindControl("liNoData").Visible = true;
}
}
}
第二个功能不执行