Link to home
Start Free TrialLog in
Avatar of Bobby X
Bobby XFlag for United States of America

asked on

need help on ControlID

Hi,

I have the code-behind below that's working just fine when I use it in regular aspx page, but once I put the dropdownlist control "ddlState" in a content page of a master page, it starts giving an error  "Could not find control 'ctl00_secondPageContent_ddlState' in ControlParameter 'state_id'.", where "secondPageContent" is the ID of the contentplaceholder containing the dropdownlist "ddlState".  Can someone tell me how to fix this?

Thanks.
odsLocs.SelectMethod = "SelectOfficeByState";
            ControlParameter stateIDParam = new ControlParameter();
            stateIDParam.ControlID = "ddlState";
            stateIDParam.Name = "state_id";
            stateIDParam.PropertyName = "SelectedValue";
            odsLocs.SelectParameters.Clear();
            odsLocs.SelectParameters.Add(stateIDParam);
            dlLocations.Caption = captionText + "<br /><br />Offices in State:";
            dlLocations.DataSource = odsLocs.Select();
            dlLocations.DataBind();

Open in new window

Avatar of guru_sami
guru_sami
Flag of United States of America image

may be try like this:
DropDownList ddl = (DropDownList)this.FindControl("ddlState");
ControlParameter stateIDParam = new ControlParameter();
stateIDParam.ControlID = ddl.ClientID;

not tested but try and see if that works..
ASKER CERTIFIED SOLUTION
Avatar of drypz
drypz
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial