Repeater嵌套

为上层绑定OnItemDataBound事件
*.aspx部分代码:
   <asp:Repeater runat="server" ID="repTest" OnItemDataBound="BindDate">
        <ItemTemplate>
            <asp:Repeater runat="server" ID="repDate">
                <ItemTemplate>
                        Eval("START_DATE")
                </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>

*.aspx.cs部分代码
    protected void BindDate(object obj, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater rep = e.Item.FindControl("repDate") as Repeater;
            DataRowView rowView = (DataRowView)e.Item.DataItem;
            string strCode = Convert.ToString(rowView["CODE"]);
            rep.DataSource =  数据源;
            rep.DataBind();
        }
    }

posted @ 2012-01-30 14:28  前端咖  阅读(208)  评论(0编辑  收藏  举报