views:

223

answers:

3

The question seems to be trivial, but i didn't found an answer with google.

If I have multiple independent controls in a web-form, e.g. DropDownLists and grid, and I need to use postback information from one eventhandler in another eventhandler, therefore i need to make it fire properly one after aonther.

I see a lot of indirect ways to do it - with raise custom event etc., but probably there is better and simpler way to do it?

UPD.: if I need to use postback info from one control in another - e.g. dropdownlist.SelectedValue in RadGrid.NeedDataSource databinding handler - what is the usual way to send it?

+1  A: 

As far as I know, the default event firing mechanism in ASP.Net does not guarantee any order. So you should design your program flow such that you don't depend on it. If you can mention your exact requirement may be that can be thought about.

Uchitha
+4  A: 

Unfortunately, you should not be constructing event handlers that rely on a firing order. This is not a recommended practice. From ASP.NET Web Server Control Event Model:

You should not create application logic that relies on the change events being raised in a specific order unless you have detailed knowledge of page event processing. For details, see ASP.NET Page Life Cycle Overview.

There is probably a flaw in your design if you are relying on this. If you post some more details, we can see if we can help you get around it.

EDIT:: Rudnev, I've used RadGrid before but I can't remember the exact purpose of the NeedDataSource event. Wouldn't it be sufficient to set your dropdownlist to automatically post back once it's been changed, and then in the event handler, set the DataSource of your Grid to the appropriate source, and call DataBind() on it?

womp
well, it is complex to discuss the particular case. i found out that there is no straight way so i have made ajaxified radgrid which doesn't need postback. But still the main question is unanswered - can we use postback info from one (or multiple) handler(s) in another handler and if the answer is - no, we should not even try, what is simplest workaround?
rudnev
A: 

If one event handler depends on the result of another, then conceptually the "event" it is responding to is the completion of the first event. I think you are stuck raising a custom event or calling the chain of methods manually, as appropriate.

James M.