Solved

need help on ControlID

Posted on 2009-07-06
2
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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