Selecting an item in a drop down list

  • Thread starter Thread starter KatMagic
  • Start date Start date
K

KatMagic

How do you force a drop down list to default to a particular item based on
its value?

I have a drop down list with options Yes, No, Maybe, All, and I would like
it to default to "All"

This is my code, what am I doing wrong?
ddlBilling.SelectedIndex =
ddlBilling.Items.IndexOf(ddlBilling.Items.FindByValue("All"))
 
That looks fine...is that the value of the dropdown or the text?

if it's the text, you need to use FindByText

Otherwise, where is this code?are you binding before?

Karl
 
Thanks everyone you were very helpful. As you suggested, I was incorrectly
attempting to select by value, when "All" was a text value. Clearing the
selection and selecting by the actual value (0), worked! Thanks.
 

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

Back
Top