Reputation: 6986
This is so frustrating. I've done this a million times! For some reason, Firefox won't select an item in my drop down list. Why? (It works find in IE)
ASPX PAGE
<asp:DropDownList ID="ddlPlan" runat="server" CssClass="TDSelect" Width="250px" AutoPostBack="true" DataTextField="Plan_Name" DataValueField="Plan_ID" />
ASPX.VB CODE BEHIND
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
GetQueryStringInfo()
If Not Page.IsPostBack Then
InitDropDowns()
LoadTasks()
SetUI()
End If
Catch ex As Exception
lblResults.Text = "Error loading page: " & TeamDynamix.Error.TDError.HandleException(Me.DbConnStr, Me.UID, ex) & ": " & ex.Message
End Try
End Sub
Private Sub InitDropDowns()
'Plan'
'LOAD PLANS'
Using oDR As SqlClient.SqlDataReader = Common.GetSPDataReader(Me.DbConnStr, "PlansSelect", _
Common.MP("@UID", SqlDbType.VarChar, 40, Me.UID), _
Common.MP("@TID", SqlDbType.Int, 4, Me.TID))
If oDR.HasRows Then
ddlPlan.DataSource = oDR
ddlPlan.DataBind()
End If
'Clean up'
oDR.Close()
End Using
'INSERT BLANK ITEM'
ddlPlan.Items.Insert(0, "")
'IF PLANID IS SET, SELECT APPROPRIATE PLAN'
If PlanID > 0 Then
If ddlPlan.Items.FindByValue(PlanID) IsNot Nothing Then
ddlPlan.SelectedValue = PlanID
End If
End If
End Sub
I've examined the rendered HTML by viewing source in FireFox. It appears to create the element correctly, and all the options (values and text are set correctly), and it also puts selected="selected" on the appropriate item in the list! So I'm not sure why the item doesn't appear selected. NOTE: It's now working, read to end of this question to see the new "real" question...
RENDERED HTML
<select id="ddlPlan" class="TDSelect" style="width: 250px;" onchange="javascript:setTimeout('__doPostBack(\'ddlPlan\',\'\')', 0)" name="ddlPlan">
<option value=""/>
<option value="517">(Copy of) AAA</option>
<option value="500">(Copy of) andrew test</option>
<option value="249">(Copy of) Test</option>
<option value="359">Brandon's Test</option>
<option value="472">BTEST2</option>
<option value="1498">Date Issue Test</option>
<option value="1516">Date Issue Test</option>
<option value="1529">Date Issue Test</option>
<option value="367">Import</option>
<option value="91">Task Import</option>
<option value="331">Task Plan Import</option>
<option value="332">Task Plan Template Test </option>
<option value="520">test 456</option>
<option value="1464">test 456</option>
<option value="1520">test 456</option>
<option value="1480">Test Checking Out</option>
<option value="1527">Test Plan</option>
<option value="560">TestPlan-B</option>
<option value="1465">TestPlan-B</option>
<option value="1521">TestPlan-B</option>
<option value="605" selected="selected">Work Items</option>
</select>
IT JUST STARTED WORKING
I just posted and answer to this because it just started working for no apparent reason whatsoever. The question then becomes: Is there some sort of caching or any other mechanism in FireFox that would cause this behavior?
Upvotes: 1
Views: 2940
Reputation: 21
I have had this issue with Firefox and I had to set the autocomplete option to "off" for the DropDownList.
Example:
<asp:DropDownList ID="ddlName" runat="server" autocomplete="off" />
Upvotes: 2
Reputation: 6986
OK, for some reason this just started working. I swear it wasn't working before, but I didn't change anything and it just started working. Could some sort of caching have been causing this issue or anything like that?
Upvotes: 0
Reputation: 1650
Interesting, do you have !Page.IsPostback wrapping around the code that binds the DropDown? If the answer is no, the DropDown is gonna be re-bound on every postback and the selected value shall be lost.
Upvotes: 1
Reputation: 3837
I noticed that you are using "Plan_ID" in the HTML and PlanID in your code behind. They should be the same.
Upvotes: 1