Solved

need help on ControlID

Posted on 2009-07-06
2
234 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:WebAppDeveloper
2 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24790246
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..
0
 
LVL 13

Accepted Solution

by:
drypz earned 500 total points
ID: 24790886
Hi! Try this one if it works


        DropDownList ddl = this.Master.FindControl("ContentPlaceHolder1").FindControl("ddlState") as DropDownList;

        stateIDParam.ControlID = ddl.ID;

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check my code out(2) 2 54
Linq Help 1 35
Need a complete list of ASP.NET page load events 3 28
Two different visual studio versions 3 23
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

16 Experts available now in Live!

Get 1:1 Help Now