0
votes

I have a wizard control which must use dynamic steps in. I have the following code which loads the dynamic steps (this all works fine). I have 7 static steps.

protected override LoadViewState(object savedState)
{
    base.LoadViewState(savedState);

    int offset = 4;
    foreach(string stepName in this.ViewState["Steps"])
    {
        WizardStep step = new WizardStep();
        step.Title = stepName;
        this.Wizard1.WizardSteps.AddAt(step, offset); // LINE 1
        this.Wizard1.WizardSteps.Add(step); // LINE 2
        offset++;
    }
}

I have two issues, when I execute the code and use Line 1. When I get to a dynamic step it won't let you procede to the next one (using the Next button). This seems to be because this.IsValid is false (but I have no validation controls on the page). It just seems to get stuck on that current page.

When I run using Line 2, it adds the steps again fine. When I am on the first dynamic step and click Next I get the error. ActiveViewIndex is being set '7'. It must be smaller than the current view controls '7'. For dynamically added views, make sire they are added before or in Page_PreInit event.

The issue with the second error is I can't add the dynamic steps in Page_PreInit because I need access to the viewstate to know how many steps to draw.

1

1 Answers

0
votes

I found the issue. Its since the steps must be added in the Page_PreInit event. Which does mean I can't use the Viewstate but I am using the Session instead now.