如何使用许多数据绑定来组织ASP.NET向导控件

时间:2021-08-12 15:53:52

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.

编辑:我应该补充一点,我已经看到了大部分的向导控制教程,但它们似乎都没有解决我想要做的事情。特别是,需要在步骤之间保存和检索数据,以及如何在重新访问步骤时再次检索相同的数据。

1 个解决方案

#1


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).

关于向导控制的一件事,因为您的工作流变得越来越复杂我认为工作流状态和向导SelectedViewIndex之间的耦合变得有问题。出于这个原因,我最终将它们分开。我通常会使用状态/状态机模式,其中当前工作流状态用于确定适当的向导视图索引(但反之亦然)。

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.

如果您正在寻找有关如何实现状态机的示例,我有一个测试应用程序可以遍历对话框,如向导控件,除了使用javascript。查看http:// main(dot)test.wishpot.com/WaveDataCollection.Frank/,进入CollectSamples.aspx页面后,继续查看源代码,然后开始在GotoState函数中查看。

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.

状态机在C#中有点不同,主要区别在于状态对象是一个具有固定数量的事件处理程序的抽象类,每个状态继承自实现每个处理程序的类(有些可能抛出异常)。使用javascript我们不需要抽象状态类...此外,在执行此服务器端时,您将需要能够从存储在数据库中的状态ID映射到状态类。

#1


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).

关于向导控制的一件事,因为您的工作流变得越来越复杂我认为工作流状态和向导SelectedViewIndex之间的耦合变得有问题。出于这个原因,我最终将它们分开。我通常会使用状态/状态机模式,其中当前工作流状态用于确定适当的向导视图索引(但反之亦然)。

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.

如果您正在寻找有关如何实现状态机的示例,我有一个测试应用程序可以遍历对话框,如向导控件,除了使用javascript。查看http:// main(dot)test.wishpot.com/WaveDataCollection.Frank/,进入CollectSamples.aspx页面后,继续查看源代码,然后开始在GotoState函数中查看。

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.

状态机在C#中有点不同,主要区别在于状态对象是一个具有固定数量的事件处理程序的抽象类,每个状态继承自实现每个处理程序的类(有些可能抛出异常)。使用javascript我们不需要抽象状态类...此外,在执行此服务器端时,您将需要能够从存储在数据库中的状态ID映射到状态类。