Results 1 to 3 of 3

Thread: How to see a control in another contentplaceholder?

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Unhappy How to see a control in another contentplaceholder?

    I'm using a masterpage and having some trouble with my ContentPlaceholders.
    I have a combobox(DropDownList1) in the sidemenu content placeholder and in my main placeholder I have a gridview. The gridview is supposed to do a select in the db using the selected value of DropDownList1. When I set up the connection SQL within the datagrid, using the wizard; I select to get a parameter from a control and then I select DropDownList1.

    NOW:
    When I try to run the page, it returns an error "Exception Details: System.InvalidOperationException: A control with ID 'DropDownList1' could not be found", however if I move DropDownList1 to the main placeholder, everything works perfectly.

    How do I get asp.net to see the control sitting in the other placeholder?

  2. #2
    Hyperactive Member jasonwucinski's Avatar
    Join Date
    Mar 2010
    Location
    Pittsburgh
    Posts
    452

    Re: How to see a control in another contentplaceholder?

    use findControl. something like this:
    dim myControl = Me.SomeControl.FindControl("dateTimePicker1").FindControl("getDateTb")

    you can use findControl for each depth
    if i was able to help, rate my post!

  3. #3

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: How to see a control in another contentplaceholder?

    Quote Originally Posted by jasonwucinski View Post
    use findControl. something like this:
    dim myControl = Me.SomeControl.FindControl("dateTimePicker1").FindControl("getDateTb")

    you can use findControl for each depth
    I tried that, but could not get it to work properly. I finally got it to work by prefixing the contentplaceholder's ID to the id of the control reference

    HTML Code:
    <asp:ControlParameter ControlID="LeftMenu$DropDownList1" Name="UserId" 
                        PropertyName="SelectedValue" Type="Int32" />

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width