troubleshooting Question

can't get ListBox SelectedValue

Avatar of SweatCoder
SweatCoderFlag for United States of America asked on
7 Comments3 Solutions677 ViewsLast Modified:
No matter what I try, I can't get the SelectedValue from my listbox on postback. I have triple-checked and even verified by stepping through code that I'm not rebinding my listbox to the datasource on postback (button click).

listbox declaration:
<asp:ListBox ID="listAvailableAMCs" Rows="8" Width="300px" DataValueField="ID" DataTextField="Company" runat="server"></asp:ListBox>

Listbox data population works fine.

A button click calls this:

protected void LinkAMC(object sender, EventArgs e)
        if(listAvailableAMCs.SelectedValue != string.Empty)


SelectedValue is always blank. SelectedText is blank and SelectedIndex is -1.

A view source reveals this html:

<select size="8" name="ctl00$MasterMain$listAvailableAMCs" id="MasterMain_listAvailableAMCs" style="width:300px;">
      <option value="19">Como AMC</option>
      <option value="21">Sinatra AMC</option>
      <option value="20">Martin AMC</option>

Those option values and text values are exactly right.

What am I missing?
Join our community to see this answer!
Unlock 3 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros