首页 新闻 会员 周边 捐助

如何绑定数据库控件repeater1中另一个repeater2控件?

0
悬赏园豆:5 [已解决问题] 解决于 2009-06-11 15:35

<anthem:Repeater ID="repeater1" runat="server" AutoUpdateAfterCallBack="True">
            <ItemTemplate>
                <ol>
                    <h5 class="h5">
                    </h5>
                    <dt>咨询人名字:<%# Eval("GUserName")%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sy4">留言时间:<%# Eval("GTime")%></span></dt>
                    <dd>
                        留言内容:<%#Eval("Gcontent") %></dd>
                    <dd>
                        回复:</dd>
                    <anthem:Repeater ID="Repeater2" runat="server">
                        <ItemTemplate>
                            <ol>
                                <dt>咨询人名字:<%# Eval("Lname")%>&nbsp;&nbsp;<span class="sy4">回复时间:<%# Eval("Ltime")%></span>&nbsp;&nbsp;联系:<%#Eval("Gcontent") %></dt>
                                <dd>回复内容:<%#Eval("Lcontent")%></dd>
                            </ol>
                        </ItemTemplate>
                    </anthem:Repeater>
                </ol>
            </ItemTemplate>
        </anthem:Repeater>

Tiger2009的主页 Tiger2009 | 初学一级 | 园豆:181
提问于:2009-06-11 13:49
< >
分享
最佳答案
0

注册Repeater1的DataItemBound事件,在事件中编写如下代码:

protected void Repeater1_DataItemBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Repeater repeater2 = e.Item.FindControl("Repeater2") as Repeater;
        if (repeater2 != null)
        {
            repeater2.DataSource = yourDataSource;
            repeater2.DataBind();
        }
    }
}

Gray Zhang | 专家六级 |园豆:17610 | 2009-06-11 13:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册