Finding a Placeholder Control inside a Repeater on Postback

Posted on 2011-10-28
Last Modified: 2012-05-12
I have a custom control placed inside a repeater. I want to get access to the values stored in it and find it on postback. But when I search for it within the placeholder on the button click event, it returns Nothing.

I want to get the value of the combobox as selected by the user prior to the submit.

See my code attached. Thanks.
Protected Sub btnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click
        If Not Page.IsValid Then Exit Sub
        Dim ph As New PlaceHolder
        ph = CType(rptItem.FindControl("RepeaterName"), PlaceHolder)
        For Each phc As Control In ph.Controls
            ' try to obtain by the ID
            If phc.ID = "MYID" Then
                Dim cmb As ICombo = CType(phc, ICombo)
                Dim valueId As Integer = CInt(cmb.GetAnswer)
            End If
            ' try to obtain by checking the interface type
            If TypeOf phc Is ICombo Then
                Dim cmb As ICombo = CType(phc, ICombo)
                Dim valueId As Integer = CInt(cmb.GetAnswer)
            End If
        end if
    End Sub

Open in new window

Question by:BobCSD
    LVL 20

    Assisted Solution

    You need to post a simplified version of your repeater, also show the placement of your BtnSave(s).

    What is the indicator we are looking for that the particular combobox was selected by the user and is therefore the one we want?

    If you have multiple BtnSave's I can see how you are expecting to determine this, but otherwise it's going to be a main focus of how to get this working.

    Anyway need some code and then we can see what other questions/solutions arise.
    LVL 1

    Accepted Solution

    I decided to skip the repeater and just use a placeholder and loop through a collection from a datareader and add to a placeholder.

    LVL 1

    Author Closing Comment

    don't think it's possible. looked everywhere. came up with another solution.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now