Adding Items To Drop Down Lists

Results 1 to 2 of 2

Thread: Adding Items To Drop Down Lists

  1. #1
    Join Date
    Dec 1969

    Default Adding Items To Drop Down Lists

    Hi<BR><BR>I have some drop down lists that I populate with values from a database. I&#039;m trying to build a search page and want to have the ability to add another item to each of my text boxes that is blank, so that when a blank value is selected I can build a data view filter string with the value "%". Can anyone show me how to do this?<BR><BR>Here is my code that I use to populate my drop down boxes.<BR><BR>Thank you.<BR><BR>&#060;CODE&#062;<BR>private void populateAuthoriser()<BR>{<BR> sqlConnection1.Open();<BR> System.Data.SqlClient.SqlDataReader dr;<BR> dr = sqlCommand4.ExecuteReader();<BR><BR> dropDownAuthorisedBy.DataSource = dr;<BR> dropDownAuthorisedBy.DataTextField = "user_name";<BR> dropDownAuthorisedBy.DataValueField = "user_code";<BR> dropDownAuthorisedBy.DataBind();<BR><BR> dr.Close();<BR> sqlConnection1.Close();<BR> <BR>}<BR>&#060;/CODE&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Adding Items To Drop Down Lists

    &nbsp;<BR>do the following after .databind<BR><BR>dropDownAuthorisedBy.Items.Insert (0, New ListItem("", "-1"))<BR><BR>this will insert an empty string at poistion 0 of the drop down. It will have a value of -1 (change this to blank too if needs be)

Posting Permissions

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