我有2个嵌套的Repeater,我的问题是关于显示结果。我希望它显示如下:
Caption1
Images1
Caption2(应该在新行但不是)
Images2
Caption3(应该在新行但不是)
Images3
但结果如下:
http://s22.postimg.org/v53xrz40h/Capture.jpg
那我怎么解决这个问题呢?
感谢。
HTML:
<asp:Repeater ID="rptReferansBaslik" runat="server" OnItemDataBound="rptReferansBaslik_ItemDataBound">
<ItemTemplate>
<p>
<asp:Label ID="lblCaption" runat="server" Text='<%#Eval("Ref_Baslik") %>'></asp:Label>
</p>
<asp:Repeater ID="rptCalismalar" runat="server">
<ItemTemplate>
<ul id="mb_imagelist" class="mb_imagelist">
<li>
<img src='images/small/<%#Eval("CI_ThumNailURL") %>' alt="image1" data-bgimg='images/big/<%#Eval("CI_ImageURL") %>' /></li>
</ul>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
代码
protected void Page_Load(object sender, EventArgs e)
{
//List<Referanslar> list = Referanslar.GetReferanslarList("");
rptReferanslar.DataSource = Referanslar.GetReferanslarList("");
rptReferanslar.DataBind();
rptReferansBaslik.DataSource = Referanslar.GetReferanslarList("");
rptReferansBaslik.DataBind();
}
protected void rptReferansBaslik_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rp = (Repeater)e.Item.FindControl("rptCalismalar");
int id = int.Parse(DataBinder.Eval(e.Item.DataItem, "Ref_ID").ToString());
rp.DataSource = CalismalarImages.GetCalismalarImagesList("SELECT * FROM CalismalarImages WHERE CI_CalismaID=" + id);
rp.DataBind();
}
答案 0 :(得分:0)
在这种情况下,我认为你应该使用ListView而不是转发器。你可以做的是创建一个listview“parentListview”,然后创建一个listview“childRepeater”,如下所示:
//Link mannually OnItemDataBound to ItemBound --
<asp:ListView ID="parentListview" runat="server" OnItemDataBound="ItemBound">
<ItemTemplate>
...
<asp:Repeater ID="childRepeater" runat="server">
<ItemTemplate>
...
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:ListView>
代码应如下所示:
parentListview.DataSource = Listtournoiterminer;
parentListview.DataBind();
然后:
protected void ItemBound(object sender, ListViewItemEventArgs args)
{
Repeater childRepeater = (Repeater)args.Item.FindControl("childRepeater");
...
childRepeater.DataSource = Top3;
childRepeater.DataBind();
}
我希望这对你有所帮助!