Re: ComboBox question

Re: ComboBox question

Old forum URL: forums.lhotka.net/forums/t/3332.aspx


ozitraveller posted on Sunday, August 05, 2007

Hi

I have 5 combos on a form, and the first one is the filter for the others. I have already written the event handlers that are activated when the user selects an item on the first combo, and my question is, how can I hook into the same events when the form opens and the first combo is bound? The SelectedValueChanged event isn't fired when databinding to the SelectedValue.

Any help would greatly appreciated.

thanks

Ozi

david.wendelken replied on Tuesday, August 07, 2007

I don't know how to do it the way you suggest, but since you know it happens on the intial page load, as a fall back, just fire off the code in the events on the initial page load.

ozitraveller replied on Tuesday, August 07, 2007

Hi David

Thanks for the suggestion. I'm trying to fit this into the MVC I've got going here. The SelectedIndexChanged event works fine when an item is selected, so I was hoping to trigger the same events when the data is bound on the filter combobox so that I could use the same event handler for both. But for some reason the databinding doesn't always trigger the event.

 

Ozi

david.wendelken replied on Thursday, August 09, 2007

I try not to put business logic in event handlers if I can help it.

I prefer to have the event handler call another method that actually does the work.  That way, I can have the same logic invoked by multiple handlers with a minimum of bother.

ozitraveller replied on Thursday, August 09, 2007

I understand what you are saying, and I agree.

This is what happens, when a user selects an item from the filter combo:

SelectedIndexChanged event is fired (UI) and the handler (controller) retrieves the data and returns the objects back to the UI via an (controller) event.

So I thought, since I had this nice pattern working, I could hook into it in when the form load and the data is loaded and bound, and get the initializition using the same logic as the combo SelectedIndexChanged event.

I'm trying to steer clear of calling the controller directly.

 

Copyright (c) Marimer LLC