2013-03-09 47 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