ASP.NET - DropDown DataBinding (Rebind?)
- by Bob Fincheimer
I have a drop down which has a method which binds data to it:
dropDown.Items.Clear()
dropDown.AppendDataBoundItems = True
Select Case selType
Case SelectionTypes.Empty
dropDown.Items.Insert(0, New ListItem("", ""))
Case SelectionTypes.Any
dropDown.Items.Insert(0, New ListItem("ANY", ""))
Case SelectionTypes.Select
dropDown.Items.Insert(0, New ListItem("Select One", ""))
End Select
BindDropDown(val)
The BindDropDown method simply sets the datasource, datakeyname, datavaluename, and then databinds the data.
For a reason which I cannot avoid, I MUST call this method twice sometimes. When it is called twice, All of the databound items show up two times, but the top item (the one I manually insert) is there only once.
Is ASP doing something wierd when i databind twice even though i clear the list between? Or does it have to do something with the viewstate/controlstate?
EDIT__
The entire page, and this control has EnableViewState="false"
EDIT___
The dropdown is inside a form view. After the selected value is set I have to rebind the dropdown just in case the selected value is not there [because it is an inactive user]. After this, the formview duplicates the databound items.