1

我有 2 个嵌套中继器,我的问题是关于显示结果。我希望它像这样显示:

标题 1

  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();
    }
4

1 回答 1

0

in this case, I think you should use ListView instead of repeater. What you can do is to create a listview "parentListview" and then a listview "childRepeater" like this :

//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>

The code should look like this :

parentListview.DataSource = Listtournoiterminer;
parentListview.DataBind();

And then :

protected void ItemBound(object sender, ListViewItemEventArgs args)
{

        Repeater childRepeater = (Repeater)args.Item.FindControl("childRepeater");

        ...

        childRepeater.DataSource = Top3;
        childRepeater.DataBind();

}

I hope this helped you !

于 2013-05-08T14:46:44.130 回答