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

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top