I have a dropdown list that I am binding to a datatable. Here is the code I am using to do it:
ddlBuildAddr.DataSource = buildings
ddlBuildAddr.DataTextField = "buildingName"
ddlBuildAddr.DataValueField = "buildingId"
Dim addressId As Int32 = OfficeData.GetInstance().GetBuildingId(currentAddress)
ddlBuildAddr.SelectedIndex = addressId
ddlBuildAddr.DataBind()
Unfortunately, the line ddlBuildAddr.SelectedIndex = addressId
is failing. Looking at this line through the debugger, the SelectedIndex
goes to -1, while addressId
goes to 2. What gives? Why would the assignment operator flatout not work?