2013-03-09 50 views
0

我有一个asp.net向导控件。我在步骤3中使用具有一些文本框的数据网格获取用户输入。网格中还有充满相关信息的lebels。在第四步中,我将处理输入并创建一些配置。asp.net向导重装同样的步骤两次

现在我需要显示信息摘要,其中包括输入信息(文本框和标签)后第3步和第4步之前。我可以创建一个新的向导步骤摘要并显示所有这些通知,但我必须创建通过填充步骤3中的所有信息,可以使用类似类型的数据网格/(或其他方式)。相反,我可以重复使用与文本框一起添加一些标签的步骤3数据网格,并仅在摘要步骤中显示它。但为了做到这一点,我必须违反向导的概念,例如在下一次按钮点击时取消当前步骤(e.cancel = true),并且有一些标志再次重新载入同一步骤,而我并不认为这是合适的办法。

你们是否有更好的办法达到这个目标?对不起,如果问题很混乱,我可以根据查询添加更多信息。

回答

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); 
      } 
     } 
    } 
} 
+0

感谢您的回复。看起来像我必须手动处理所有事情。我'有点犹豫要做这个方法,因为对我来说,其余的步骤是和完整的,但只有这个简单的步骤,我必须改变和手动处理一切? – Reuben 2013-03-09 17:28:04

+0

它不需要完全手动。上述方法仅用于*当*你需要分支时,否则就让它正常运行。我的例子看起来很复杂,因为该功能需要的所有分支。 – 2013-03-09 18:03:46

+0

真的..谢谢你的回答.. – Reuben 2013-03-09 18:17:43