ASP.Net:检索在中继器DataBound上动态添加的用户控件

时间:2018-08-30 14:32:03

标签: asp.net user-controls repeater

我要在item-databound上将用户控件动态添加到转发器。问题是我在以后的事件(例如保存)上找不到用户控件。

<asp:Repeater runat="server" ID="rptTabContainers">
     <ItemTemplate>
          <asp:Panel runat="server" ID="pnlBody" ClientIDMode="Predictable" CssClass="panel-body">
          </asp:Panel>
     </ItemTemplate>
</asp:Repeater>

胜过itemdatabound:

For Each r As DataRow In items.Rows
    Dim ItemType As String = r.Item("ItemType").ToString()

    Select Case ItemType
        Case "CheckBoxList", "RadioButtonList"
            Dim ctr As ctrl_VAMportfolio_CheckBoxList = CType(LoadControl("~/DW2/include/code/controls/VAM/ctrl_VAMportfolio_CheckBoxList.ascx"), ctrl_VAMportfolio_CheckBoxList)
            With ctr
                .ItemNumber = r.Item("ItemNo").ToString()
                .ItemText = r.Item("ItemText").ToString()
                .ID = String.Format("ctrl_{0}_{1}", DomainID, r.Item("ItemNo"))
                .ListItems = XMLtoList(r.Item("ItemOptions"))
                .MultipleSelect = (ItemType = "CheckBoxList")
                .ClientIDMode = ClientIDMode.Static

            End With

            pnlBody.Controls.Add(ctr)

        Case "ctrlRadioAndTextExplanation"
            Dim ctr As ctrlRadioAndTextExplanation = CType(LoadControl("~/DW2/include/code/controls/VAM/ctrlRadioAndTextExplanation.ascx"), ctrlRadioAndTextExplanation)
            With ctr
                .ItemNumber = r.Item("ItemNo").ToString()
                .ID = String.Format("ctrl_{0}_{1}", DomainID, r.Item("ItemNo"))
                .ClientIDMode = ClientIDMode.Static
            End With
            pnlBody.Controls.Add(ctr)

        Case "Upload", "Download"
            Dim ctr As ctrl_VAMportfolio_Upload = CType(LoadControl("~/DW2/include/code/controls/VAM/ctrl_VAMportfolio_Upload.ascx"), ctrl_VAMportfolio_Upload)
            With ctr
                .ItemNumber = r.Item("ItemNo").ToString()
                .ItemText = r.Item("ItemText").ToString()
                .DomainID = DomainID
                .PortfolioID = EvaluationID
                .ID = String.Format("ctrl_{0}_{1}", DomainID, r.Item("ItemNo"))
                .ClientIDMode = ClientIDMode.Static

            End With

            Dim fu As New FileUpload()
            fu.ID = String.Format("FileUpload{0}_{1}", DomainID, r.Item("ItemNo"))
            fu.AllowMultiple = True
            fu.Attributes.Add("style", "display:none;")

            pnlBody.Controls.Add(ctr)
    End Select
Next

好吧,我正在尝试从转发器中的用户控件中获取数据,但是它什么也不返回。

谢谢您的帮助

0 个答案:

没有答案