I guess I'll bore you with the details ;-)
The control selections are populated from preset values gathered from a database. The selected item is the matching value in a set of other records. Lets say the combobox is to select a person's age range. There are several items populating the combobox but none are selected - yet. Now lets imagine that for the current record, age_range evaluates to null. Because the values of other controls are set according to the selected value of the combobox, setting it to the incorrect value results in other values being incorrect. Plus, to add more onto this, on postback, if a value is selected that is incorrect, it will corrupt the data. This needs to be a value that is not selected and is picked up by the server side code as being invalid. The default item is selected whenever there is no valid item that can be selected and the data is safe.
The vendor was only aware of the issue on Friay after I brought it to their attention. They have no workaround as of yet because they have still not acknowledged it is a bug. After providing them with code and the steps to recreate the behavior, I suspect they will do so today.
Their first response was this is the expected behavior, except their own code that they said works as expected also has the same problem. The problem with their assertion is the client side event fires, but the server side event does not. Of course this is only the case when the top item in the combobox is selected first when the default item is currently selected.
Anyway, I was thinking that because I don't need to fire any events except the SelectedIndexChanged event, I could just handle the postback in the codebehind and fire it manually each time the combobox initiates a postback. I can probably do that by using the client side event and calling __doPostBack from the client code as long as I set AutoPostBack to false. This way, in the code behind, if I get a postback that is initiated from the control, I can call the appropriate function to ensure the changes are applied.
Something like this in the code behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Page.IsPostBack) Then
If (Request.Form("__EVENTTARGET") = "MyComboBox") Then
MyComboBox_SelectedIndexChanged(MyComboBox , New EventArgs)
End If
End If
End Sub
and something like this in the client code:
<tpv:ComboBox ID="MyComboBox" AutoPostBack="false" OnClientSelectedIndexChanged="MyComboBox_SelectedIndexChanged" runat="server" />
<script type="text/javascript">
function MyComboBox_SelectedIndexChanged(sender, args){
__doPostBack('MyComboBox', '');
}
</script>
Is this workable? Are there any issues I need to be aware of?