Below is the wizard code.
<asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="false" OnNextButtonClick="Wizard1_NextButtonClick"
CssClass="" OnFinishButtonClick="Wizard1_FinishButtonClick" FinishCompleteButtonText="Publish" OnLoad="Wizard1_Load" OnInit="Wizard1_Init"
OnPreviousButtonClick="Wizard1_PreviousButtonClick" Width="100%" ActiveStepIndex="-1" EnableViewState="false" > <%--OnLoad="Wizard1_Load" OnInit="Wizard1_Init"--%>
<WizardSteps>
<asp:WizardStep ID="wzsKeyData" runat="server" Title="KeyData">
<div class="bidpost" style="padding-bottom:80px;">
<asp:PlaceHolder ID="phKeyData" runat="server"></asp:PlaceHolder>
</div>
</asp:WizardStep>
<asp:WizardStep ID="wzsTechnical" runat="server" Title="Technical">
<div class="bidpost" style="padding-bottom:80px;">
<asp:PlaceHolder ID="phTechSpecification" runat="server"></asp:PlaceHolder>
</div>
</asp:WizardStep>
<asp:WizardStep ID="wzsCommercial" runat="server" Title="Commercial">
<div class="bidpost" style="padding-bottom:135px;">
<div class="row-fluid" style="text-align:left;font-weight:bold;">
<div class="span2">
<asp:Label ID="lblBidQuote" runat="server" Text="Bid Quote"></asp:Label>
</div>
<div class="span4">
<asp:TextBox ID="txtBidQuote" runat="server" PlaceHolder="E.g. 45678" CssClass="inputMargin" MaxLength="10" style="width:180px;"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="ftxtBidQuote" runat="server" Enabled="True" TargetControlID="txtBidQuote"
ValidChars="0123456789">
</cc1:FilteredTextBoxExtender>
<asp:RequiredFieldValidator runat="server" ID="rfvtxtBidQuote" ControlToValidate="txtBidQuote" InitialValue=""
ValidationGroup="validatebid" ForeColor="Red" Display="Dynamic" ErrorMessage="Please Enter Bid Quote!" />
</div>
<div class="span2 inputMargin">
<asp:Label ID="lblDeliveryDate" runat="server" Text="Delivery Date"></asp:Label>
</div>
<div class="span4">
<asp:TextBox ID="txtDeliveryDate" placeholder="E.g. February 18, 2016" CssClass="textBox spaninner datepickr" runat="server"> </asp:TextBox>
<i class=" fa fa-calendar calendar-icon calendar-icondeliverydate" style="top:-7px;"></i>
<asp:RequiredFieldValidator runat="server" ID="rfvtxtDeliveryDate" ControlToValidate="txtDeliveryDate" InitialValue=""
ValidationGroup="validatebid" ForeColor="Red" Display="Dynamic" ErrorMessage="Please Enter Delivery Date!" />
</div>
</div>
<asp:PlaceHolder ID="phCommercial" runat="server"></asp:PlaceHolder>
</div>
</asp:WizardStep>
<asp:WizardStep ID="wzsStatutory" runat="server" Title="Statutory">
<div class="bidpost" style="padding-bottom:80px;">
<asp:PlaceHolder ID="phStatutory" runat="server"></asp:PlaceHolder>
</div>
</asp:WizardStep>
<asp:WizardStep ID="wzsOthers" runat="server" Title="Others">
<div class="bidpost" style="padding-bottom:80px;">
<asp:PlaceHolder ID="phOtherTerms" runat="server"></asp:PlaceHolder>
</div>
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<ul id="wizHeader" class="bidpostwizheader">
<asp:Repeater ID="SideBarList" runat="server">
<ItemTemplate>
<li><a class="<%# GetClassForWizardStep(Container.DataItem) %>" title="<%#Eval("Name")%>">
<%# Eval("Name")%></a> </li>
</ItemTemplate>
</asp:Repeater>
</ul>
</HeaderTemplate>
<StartNavigationTemplate>
<div class="wizardbottomdiv">
<asp:Button ID="StartNextButton" runat="server" CssClass="buttonNext" CommandName="MoveNext"
Text="Next" />
</div>
</StartNavigationTemplate>
<StepNavigationTemplate>
<div class="wizardbottomdiv">
<asp:Button ID="StepNextButton" runat="server" CssClass="buttonNext" CommandName="MoveNext"
Text="Next" />
<asp:Button ID="StepPreviousButton" runat="server" CssClass="buttonPrevious" CommandName="MovePrevious"
Text="Previous" />
</div>
</StepNavigationTemplate>
<FinishNavigationTemplate>
<div class="wizardbottomdiv">
<asp:Button ID="StepNextButton" runat="server" CssClass="buttonNext" CommandName="MoveComplete"
Text="Save Response" />
<asp:Button ID="StepPreviousButton" runat="server" CssClass="buttonPrevious" CommandName="MovePrevious"
Text="Previous" />
</div>
</FinishNavigationTemplate>
</asp:Wizard>
In this page i show list of services and sections affiliated with it.so when user clicks on a service the wizard shows all the sections of this service. Initially there were 5 fixed steps but now i have to add steps from db in addition to these five steps and it does add those steps.
Now the problem.Suppose if a service has more than 5 section(6-7) than in that case those sections(6th and 7th)will be added from code behind.So when the user reaches 6th or 7th section and clicks on the service again ,instead of populating wizard again, nothing happens.In the browser console it shows error that active viewindex out of bound.Current view index was 5 which is larger than item count.
I've tried almost everything.Setting activestepindex=0 in aspx page,page_init,Page_preinit,Page_preload,Page_load,Serviceclick events. adding wizardsteps from code behind-in this case i kept the structure of wizard (header template and navigation template) as it is and removed all those 5 fixed steps from aspx page.then on service name click i add all those steps from code behind.I've also tried calling this function in page_init,Page_preinit,page_load as the error was suggesting to bind views in page_preinit.Before binding i made sure that the active step index was set to either 0 or the old one if the item count is greater than index.
I guess the index from viewstate of control is again loaded before rendering.I've also tried setting EnableViewstate to false for this wizard but even that doesn't work.
We couldn't find the solutions so we replaced the wizard with literals and divs as wizard wasn't working well