在page_load之后为用户控件添加值throw databinding?

时间:2012-02-16 16:08:02

标签: asp.net

在更新面板中安装一个带有用户控件的转发器。

<asp:Repeater id="repQuestionElement" runat="server"
    OnItemCommand="repQuestionElement_ItemCommand"         
    OnItemDataBound="repQuestionElement_ItemDataBound">
    <ItemTemplate>
        <uc1:elements ID="Elements1" runat="server" ctrl="<%#((testElements.EditorControl.EControl)Container.DataItem)%>" />
    </ItemTemplate>
</asp:Repeater>

用户控制。

public EControl ctrl { get; set; }    

protected void Page_Load(object sender, EventArgs e)
{
    if (ctrl != null)
    {
        if (ctrl.Lb != null && ctrl.C != null)
        {
            lblQuestion.Text = ctrl.Lb;
            plhUser.Controls.Add(ctrl.C);
        }
    }
}

当我在page_load中设置数据源和数据绑定(到EControl数组)时,它正常工作,但是当我在page_load之后执行它时,没有加载用户控件。 ctrl为null。

有人知道为什么吗?

0 个答案:

没有答案
相关问题