selected item in dropdown not saved on postback
My dropdowns which are populated from db are not saving when form is submitted...all other fields working correctly AND all dropdowns not populated with db working correctly. View source on client-side shows dropdowns with correct values.
code to populate dropdown on code-behind page:
'set room dropdown
Dim myReader As SqlDataReader
SqlConnection1.Open()
myReader = SqlCommand5.ExecuteReader
room.DataSource = myReader
room.DataBind()
myReader.Close()
code on aspx page for dropdown:
<asp:dropdownlist id="room" runat="server" DataValueField="RoomID" DataTextField="Name" DataMember="Rooms" CssClass="small"></asp:dropdownlist>
code to try and insert dataselection from dropdown:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SqlConnection1.Open()
SqlCommand1.Parameters.Item("@room").Value = room.SelectedItem.Value
SqlCommand1.ExecuteNonQuery()
SqlConnection1.Close()
End Sub
when executing code, i get no errors, when stepping through, value on room.selecteditem.value is always 1 no matter what selection I make. I inserted an onselectionchanged event to fire when a new item was picked from the dropdown, but it never fires, although the new selection is shown client-side.
this is driving me crazy! any ideas???? anyone?
|