绑定向导时出错

本文关键字:出错 向导 绑定 | 更新日期: 2023-09-27 18:36:47

下面是向导代码。

<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>

在此页面中,我显示与 it.so 相关的服务和部分的列表,当用户单击服务时,向导将显示该服务的所有部分。最初有 5 个固定步骤,但现在除了这五个步骤之外,我还必须从 db 添加步骤,它确实添加了这些步骤。

现在问题来了。假设如果服务具有超过 5 节 (6-7),那么在这种情况下,这些节(第 6 节和第 7 节)将从代码隐藏中添加。因此,当用户到达第 6 或第 7 部分并再次单击服务时,而不是再次填充向导,没有任何反应。在浏览器控制台中,它显示活动视图索引超出界限的错误。当前视图索引为 5,大于项目计数。

我几乎尝试了所有方法。在 aspx 页中设置 activestepindex=0,page_init,Page_preinit,Page_preload,Page_load,Serviceclick 事件。从代码后面添加向导步骤 - 在这种情况下,我保持了向导的结构(标头模板和导航模板)不变,并从 ASPX 页面中删除了所有这 5 个固定步骤。然后在服务名称上单击我从代码隐藏中添加所有这些步骤。我还尝试在 page_init,Page_preinit,page_load 中调用此函数,因为该错误建议在 page_preinit 中绑定视图。在绑定之前,我确保活动步骤索引设置为 0 或旧索引(如果项目计数大于索引)。

我想在渲染之前再次加载来自控件视图状态的索引。我还尝试将此向导的启用视图状态设置为 false,但即使这样也不起作用。

绑定向导时出错

我们找不到解决方案,所以我们用文字和div 替换了向导,因为向导不能很好地工作