Can't Find DropdownList inside a Sharepoint Control? Items.Add..Value does not fall within the expec

  • Thread starter Thread starter jc
  • Start date Start date
J

jc

The DDL is an ASP Dropdownlist inside a Sharepoint formwebpart. I
have a C# script code block where I'm just trying to populate a DDL..
but I can't seem to get to it. I'm using Sharepoint Designer and
somewhat of a C# noob so I'm struggling and taking baby steps.

<asp:DropDownList runat="server" id="FacilityDDL"
DataTextField="Title" DataValueField="Title" /></td>

If I try this

Page_OnLoad

FacilityDDL.Items.Add("x");

I get
Value does not fall within the expected range.

This comes back without errors, but does nothing.

DropDownList fddl = (DropDownList)this.Page.FindControl
("FacilityDDL");
fddl.Items.Add("x");

If I try it on Page_Prerender
I get Object reference not set to an instance of an object

How can I confirm fddl found it? I'm presuming I don't need to
databind.

thanks for any help or information!
 
Back
Top