How to get controls from a placeholder

5 posts, 0 answers
  1. Peny
    Peny avatar
    16 posts
    Member since:
    Apr 2011

    Posted 04 Jul 2011 Link to this post

    Hello,

    I have a placeholder inside an update panel as showing in the below Code block.
    <tr>
    <
    td>
    <
    asp:UpdatePanel ID="UpdatePanel36" runat="server" UpdateMode="Conditional">
    <
    ContentTemplate>
    <
    asp:PlaceHolder runat="server" ID="Fields">
    </
    asp:PlaceHolder>
    </
    ContentTemplate>
    <
    Triggers>
    <
    asp:AsyncPostBackTrigger ControlID="DropDownList2" />
    </
    Triggers>
    </
    asp:UpdatePanel>
    </
    td>
    </
    tr>
    I dynamically create some Comboboxes as showing below
    .....
    Dim dropDownList As DropDownList
    dropDownList =
    New DropDownList
    dropDownList.ID = array_action_ids(i)
    dropDownList.Visible =
    True
    dropDownList.DataSourceID =
    "SqlDataSource2"
    dropDownList.DataTextField =
    "LEGAL_PHONE_NUMBER"
    dropDownList.DataValueField =
    "LEGAL_PHONE_ID"
    Fields.Controls.Add(GetLiteral("<td>"))
    Fields.Controls.Add(dropDownList)
    Fields.Controls.Add(GetLiteral(
    "</td>"))
    .....

    I also have a submit button.
    I want to get the selected value of the dropdownlist when the button is clicked.

    I tried
    Dim dropdownlist_phone As DropDownList = CType(Fields.FindControl("DropDownList_Phone"), DropDownList)

    but it didn't work. I also tried
    Dim temp_Placeholder as Placeholder = CType(UpdatePanel36.FindControl("Fields"), Placeholder)
    Dim
    dropdownlist_phone As DropDownList = CType(temp_Placeholder.FindControl("DropDownList_Phone"), DropDownList)

    but it didnt either work.
    The controls of the Fields placeholder seems to be nothing in both approaches.

    Could you please help me?

    Thanks in advance,
    Peny

  2. Prangadj
    Prangadj avatar
    174 posts
    Member since:
    Jan 2008

    Posted 04 Jul 2011 Link to this post

    Peny, you mistaken ms asp.net forums with telericks? No telerick controls in your code, ask other place.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peny
    Peny avatar
    16 posts
    Member since:
    Apr 2011

    Posted 05 Jul 2011 Link to this post

    Hello ,

    I am sorry for the wrong post ...

    I am new in asp.net and telerik programming, so I didnt exactly where to ask.
    Is there a way to do this with telerik controls?

    Regards,
    Peny
  5. Prangadj
    Prangadj avatar
    174 posts
    Member since:
    Jan 2008

    Posted 05 Jul 2011 Link to this post

    If this does not work with MS controls, it won't work with telericks as your logic is not good. Make sure you create dropdowns on page init or page load and no later. May also read this asp.net tutorial:
    http://www.aspnettutorials.com/tutorials/controls/control-dym-aspnet2-csharp.aspx

    Prangadj
  6. Peny
    Peny avatar
    16 posts
    Member since:
    Apr 2011

    Posted 05 Jul 2011 Link to this post

    Hello Prangadj,

    I really appreciate your help!!!

    I cannot create the controls on page init because the controls creation depends on the value of an other dropdown list and i dont know from the beggining which controls should be created.

    Peny
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017