別のリピーターの 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;
}
}
}
2番目の関数は実行されません