I have a form with a ComboBox
that provides a dropdownlist. On the comboBox's SelectedIndexChanged event
, am running some code, but I don't want that code to run when the form loads. Unfortunately, when I load the form (before I make a selection in the combobox), SelectedIndexChanged
of the combobox fires (I think when the combobox is databinding
). Is there a way of avoiding such behaviour?
You can simply unbind the SelectedIndexChanged event, call your fill function and bind the SelectedIndexChanged event again.
You may use Tag property of combobox. It can be empty or 0 integer value when it's empty or have not fulfilled yet. You have to set combobox's Tag as count of it's items after bounding. In SelectedValueChanged event if the Tag property is null or 0 you have to return from void.
The SelectedIndexChanged event of ASP.Net DropDownList When an item is changed in ASP.Net DropDownList, the following OnSelectedIndexChanged event handler is executed. Inside the event handler, the selected Text and Value of the DropDownList Selected Item is fetched and displayed using JavaScript Alert message box.
If you want to react only when the user change the selected item in the combo box, then it is better to subscribe to SelectionChangeCommitted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With