populate DropDownList control

Results 1 to 2 of 2

Thread: populate DropDownList control

  1. #1
    Join Date
    Dec 1969

    Default populate DropDownList control

    Hi,<BR>I want to populate a dropdownlist from a dataReader but need to make the first item display as "[Select an item from the list]". How do I add one initial static item when the rest of the listitems are read from the db?<BR><BR>I tried adding a list item after the:<BR>&#060;asp:DropDownList id="companyList" DataTextField="type_desc" DataValueField="type_key" runat="server" /&#062;<BR>but that didn&#039;t work.

  2. #2
    Join Date
    Dec 1969

    Default Ta Da!

    This is how<BR><BR>lbxMyList.Items.Insert(0,new ListItem("--Select Item--",0))<BR><BR>The first 0 represents its place in the list and the second one represents the value "--Select Item--" will hold.

Posting Permissions

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