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?
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
Re: How to see a control in another contentplaceholder?
Quote:
Originally Posted by
jasonwucinski
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" />