Reputation: 751
I have a problem that each time i bind a listbox the selected index change event fires and causes errors. Is there any way i can halt this event when binding the listbox.
Upvotes: 0
Views: 316
Reputation: 30097
You can do a work around. Keep a bool variable and set it to true while binding the listbox. When the event raises check of the variable is set to true ignore the event and set the variable to false
//something like this
bool isBinding = false;
//when binding
isBinding = true;
listbox.DataBind();
//in the selection change event
if(isBinding)
{
isBinding = false;
return;
}
Upvotes: 2