G
Guest
I must be missing something obvious. I have a drop down list in asp.net and it populates the states from a database. When I view the source of the page I get the standard option tags with the associated values. It all looks good. When I submit the form and some of the required fields aren't filled in the dropdown always reset to the first item in the list. First, how do I get it to stick. I've tried setting enableviewstate to true, but this does not seem to help. Second, and probably related, is that once the form is valid, it always passes the first item in the list regardless of which item is selected. I'm using the code below to set the value.
cboStateProvince.SelectedValue
And I'm populating the dropdown with the following code.
oda.SelectCommand.CommandType = CommandType.StoredProcedure
oda.Fill(ods)
cboStateProvince.DataSource = ods
cboStateProvince.DataValueField = "StateProvinceDisplayID"
cboStateProvince.DataTextField = "StateProvinceCombined"
cboStateProvince.DataBind()
Any suggestions?
Thanks,
Todd Meister
cboStateProvince.SelectedValue
And I'm populating the dropdown with the following code.
oda.SelectCommand.CommandType = CommandType.StoredProcedure
oda.Fill(ods)
cboStateProvince.DataSource = ods
cboStateProvince.DataValueField = "StateProvinceDisplayID"
cboStateProvince.DataTextField = "StateProvinceCombined"
cboStateProvince.DataBind()
Any suggestions?
Thanks,
Todd Meister