绑定向导时出错

时间:2016-03-01 09:28:21

标签: c# asp.net wizard multiview

以下是向导代码。

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

在此页面中,我显示了与其关联的服务和部分列表。因此,当用户单击服务时,向导会显示此服务的所有部分。 最初有5个固定步骤,但现在除了这五个步骤之外我还需要从db添加步骤,它确实添加了这些步骤。

现在问题。如果一个服务有超过5个部分(6-7)的假设,那么这些部分(第6个和第7个)将从后面的代码中添加。所以当用户到达第6或第7个部分并点击时再次在服务上,而不是再次填充向导,没有任何反应。在浏览器控制台中,它显示错误,即活动viewindex超出限制。当前视图索引为5,大于项目计数。

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

我想在渲染之前再次加载来自viewstate of control的索引。我还尝试将EnableViewstate设置为false,但是即使这样也无法工作。

1 个答案:

答案 0 :(得分:0)

我们找不到解决方案所以我们用向导替换了向导,因为向导运行不正常