R – How to organize ASP.NET Wizard control with many databinds

asp.netcontrolswizard

I've got a wizard control that databound controls on each step. I can't databind them all at once because they are dependent on the previous step. So, essentially what I've got at each step is a save to the database of the previous step, and an initialization of the current step.

Are there any recommendations as to how best to organize my code? It works, but it's not very readable, and extremely brittle.

EDIT: I should add that I've seen most of the wizard control tutorials out there, but none of them seem to address what I'm trying to do. In particular, the need to save and retrieve data between steps, and how to keep it from retrieving that same data again if the step is revisited.

Best Answer

What you've done sounds reasonable.. Can you be more specific about the problem you are having?

One thing about the wizard control, as your workflow gets more and more complex I think the coupling between your workflow state and the wizard SelectedViewIndex becomes problematic. For this reason I eventually separate them. I will usually use a state/statemachine pattern, where the current workflow state is used to determine the appropriate wizard view index (but not vice-versa).

If you're looking for examples on how to implement a state machine, I have a test app out there that walks through dialogs like a wizard control, except using javascript. Check out http://main(dot)test.wishpot.com/WaveDataCollection.Frank/, after you get to the page CollectSamples.aspx, go ahead and view source, then start reviewing at the GotoState function.

State machines are plumbed a bit different in C#, the main difference being the state object is an abstract class with a fixed number of event handlers, which each state inheriting from that class implementing each handler (some perhaps throwing an exception). With javascript we don't need the abstract state class... Also, doing this serverside, you're going to need to be able to map from a state ID stored in your database to a state class.

Related Topic