我有一个asp.net向导控件。我在第3步中使用带有一些文本框的datagrid获得用户输入。网格也有lebels,其中包含一些相关信息。在第四步中,我将处理输入并创建一些配置。
现在我需要在步骤3之后和步骤4之前显示包含输入信息(文本框和标签)的信息摘要。我可以创建一个新的向导步骤以进行摘要并显示所有这些信息,但我必须创建一个通过填充步骤3中的所有信息,类似的datagrid /(或其他方式)。相反,我可以重复使用添加了一些标签的步骤3 datagrid以及文本框,并仅在摘要步骤中显示它。但为了做到这一点,我必须违反向导的概念,如在下一个按钮点击期间取消当前步骤(e.cancel = true)并有一些标志再次重新加载同一步骤,我觉得不合适办法。
你们有更好的方法来实现这个目标吗?很抱歉,如果问题令人困惑,我可以根据查询添加更多信息。
答案 0 :(得分:0)
如果要将其合并到当前向导中,则需要手动处理ActiveStepChanged
事件,并使用向导历史记录确定应加载哪个步骤。
这将让你走完最后一步:
/// <summary>
/// Gets the last wizard step visited.
/// </summary>
/// <returns></returns>
private WizardStep GetLastStepVisited()
{
//initialize a wizard step and default it to null
WizardStep previousStep = null;
//get the wizard navigation history and set the previous step to the first item
var wizardHistoryList = (ArrayList)wzServiceOrder.GetHistory();
if (wizardHistoryList.Count > 0)
previousStep = (WizardStep)wizardHistoryList[0];
//return the previous step
return previousStep;
}
这是我前一段时间写的一些逻辑,与您尝试做的类似:
/// <summary>
/// Navigates the wizard to the appropriate step depending on certain conditions.
/// </summary>
/// <param name="currentStep">The active wizard step.</param>
private void NavigateToNextStep(WizardStepBase currentStep)
{
//get the wizard navigation history and cast the collection as an array list
var wizardHistoryList = (ArrayList)wzServiceOrder.GetHistory();
if (wizardHistoryList.Count > 0)
{
var previousStep = wizardHistoryList[0] as WizardStep;
if (previousStep != null)
{
//determine which direction the wizard is moving so we can navigate to the correct step
var stepForward = wzServiceOrder.WizardSteps.IndexOf(previousStep) < wzServiceOrder.WizardSteps.IndexOf(currentStep);
if (currentStep == wsViewRecentWorkOrders)
{
//if there are no work orders for this site then skip the recent work orders step
if (grdWorkOrders.Items.Count == 0)
wzServiceOrder.MoveTo(stepForward ? wsServiceDetail : wsSiteInformation);
}
else if (currentStep == wsExtensionDates)
{
//if no work order is selected then bypass the extension setup step
if (grdWorkOrders.SelectedItems.Count == 0)
wzServiceOrder.MoveTo(stepForward ? wsServiceDetail : wsViewRecentWorkOrders);
}
else if (currentStep == wsSchedule)
{
//if a work order is selected then bypass the scheduling step
if (grdWorkOrders.SelectedItems.Count > 0)
wzServiceOrder.MoveTo(stepForward ? wsServicePreview : wsServiceDetail);
}
}
}
}