Here is the code used to load and bind to the ddl control:
Within the html Table on the ascx form, here is the row that contains the drop down control:
<tr valign="top">
<td class="SubHead" width="200px" >
<dnn:label id="lblState" controlname="ddlState" runat="server" suffix=":" />
</td>
<td class="style6">
<asp:DropDownList ID="ddlState" runat="server" Width="116px" Height="22px" />
</td>
<td>
<asp:RequiredFieldValidator ID="rfvState" runat="server" resourcekey="valState" ControlToValidate="ddlState" ValidationGroup="Submit" InitialValue="SS" />
</td>
</tr>
Module Level assignment:
Private stateList As ListEntryInfoCollection = Nothing
In the Page_Load method, inside of a If Not Page.IsPostBack statement I have the following code:
stateList = ListCtlr.GetListEntryInfoCollection(
Dim ListCtlr As New ListController()"Region", "Country.US")Me.ddlState.DataSource = stateListMe.ddlState.DataTextField = "Text"
Me.ddlState.DataValueField = "Value"
Try
Me.ddlState.DataBind()Me.ddlState.Items.Insert(0, New ListItem("Select State", "SS"))Catch ex As ExceptionEnd Try
The ddlState control has EnableViewState to TRUE in the ascx code...
The States appears, including the Select State, which is the first item in the list. I can select the state in the dropdownlist, and all appears to be fine.
However, when I try to pull the data from the form field TextBox and DDL controls, the ddlState is completely empty. No DataSource, no DataValueField, no DataTextField, nothing...The SelectedListIndex is -1 (Not zero, which is is when the page displays). I'm completely baffled...