dropdownlist missing option text

  • Thread starter lonestarprogramming
  • Start date
L

lonestarprogramming

Hi,

I am experiencing problems with a dropdownlist.

Here is the situation: The user selects a name from a dropdownlist
(cboNames). Then the user selects an account from another dropdownlist
(cboAccounts). These selections are stored in the properties of a
custom object called FinTrans:

FinTrans.Name = cboNames.SelectedValue
FinTrans.Account = cboAccount.SelectedValue

I have a collection of these FinTrans objects that I want to navigate
through, displaying the properties on the web page. I keep track of the
index of the currently displayed FinTrans object. When the user clicks
btnNext, the index is incremented by 1, and the properties for the
FinTrans object at that index in the collection are displayed. Same for
btnPrevious, but the index is decreased by 1.

Here is how I set the dropdownlists to the correct item:
cboNames.SelectedValue = FinTrans.Name
cboAccount.SelectedValue = FinTrans.Account

I have all that working. The problem is, when navigating back and forth
between the FinTrans objects, cboAccounts seems to missing the text for
any items that have been selected. For example, if I select Account3
from the dropdown list, there is a blank line where Account3 is
supposed to be in the list:

Account1
Account2

Account4
Account5

The html source looks like this when displaying the first FinTrans
object for which I have selected Account3:
<option selected="selected" value="3">Account3</option>

When displaying subsequent FinTrans objects with Account3 selected, the
html source looks like this:
<option selected="selected" value="3"></option>

Notice it is missing the text "Account3".

I only fill cboAccounts one time (in the page load event, inside an If
not Page.IsPostBack block), using a datareader.

This seems like a complicated post. I hope you can decipher it and let
me know if you have any thoughts on why this may be happening and what
I can do about it.
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top