DropDownList and Array and...I'm stuck!

Results 1 to 2 of 2

Thread: DropDownList and Array and...I'm stuck!

  1. #1
    Join Date
    Dec 1969

    Default DropDownList and Array and...I'm stuck!

    Normally I would pull from a lookup table in the DB but seems kinda silly for a never-changing a list of months. SO, i&#039;m trying to use an array but page will not load. I think I&#039;m close but getting errors no matter what I try. Most current is:<BR>&#039;System.String&#039; does not contain a property with the name FMonth.<BR><BR>Sub Page_Load(obj as Object, E As EventArgs)<BR>If Not Page.IsPostBack Then<BR> FMonths()<BR>End Sub<BR><BR>Sub FMonths()<BR> Dim alFMonths As New ArrayList<BR> alFMonths.Add("January")<BR> alFMonths.Add("February") <BR> alFMonths.Add("March")<BR> <BR> &#039;Databind listbox Web control<BR> lbFMonths.DataSource = alFMonths<BR> lbFMonths.DataBind()<BR>End Sub<BR><BR>-----<BR>Then on my page my control looks like this:<BR>&#060;asp:dropdownlist ID="lbFMonths" DataTextField="FMonth" DataValueField="FMonthID" runat="server"&#062;&#060;/asp:dropdownlist&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: DropDownList and Array and...I'm stuck!

    You are adding strings to your ArrayList:<BR><BR> alFMonths.Add("January") <BR> alFMonths.Add("February") <BR> alFMonths.Add("March") <BR><BR><BR>Then telling the control that FOR EACH databound item find it&#039;s "FMonth" and "FMonthID" properties and bind them to the DropdownList fields.<BR><BR> &#060;asp:dropdownlist ... DataTextField="FMonth" DataValueField="FMonthID"...<BR><BR>If you want to do that, create a simple DataClass with "FMonth" and "FMonthID" properties and add instances of *it* to your ArrayList.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts