【问题标题】:asp.net one more updatepanel is not workingasp.net 又一个更新面板不工作
【发布时间】:2011-11-28 20:51:59
【问题描述】:

我在一个 aspx 页面上添加了 3 个更新面板。两个更新面板包括 gridview。我让 gridview 分页。两个按钮在单击时填充这个 gridviews。我设置了它们两个触发器和条件状态。第三个更新面板包括文本框。我设置了 updatemode有条件的,触发第三个按钮。

我的问题是,当我单击第一个第三个按钮时,我从 gridview 中选择检查的数据字段,成功运行。 但是当我单击后单击时,第三个更新面板和网格视图分页不起作用。

<asp:UpdatePanel ID="UpdatePanelWorkFLow" runat="server">
    <%--<Triggers>
    <asp:PostBackTrigger ControlID="btnGenerate" />
    </Triggers>--%>
    <ContentTemplate>
        <asp:GridView ID="GridWorkFlow" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            EnableSortingAndPagingCallbacks="false" CellPadding="4" ForeColor="#333333" GridLines="None"
            OnPageIndexChanging="GridWorkFlow_PageIndexChanging">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:TemplateField ShowHeader="true" HeaderText="Seç">
                    <ItemTemplate>
                        <asp:CheckBox ID="checkWorkFlow" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField Visible="False">
                    <ItemTemplate>
                        <asp:Label ID="labelWorkFlowId" runat="server" Text='<%# Eval("WorkFlowId")%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="WorkFlow Adi">
                    <ItemTemplate>
                        <asp:Label ID="labelWorkFlowName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Birincil Entity Adi">
                    <ItemTemplate>
                        <asp:Label ID="labelPrimaryEntity" runat="server" Text='<%# Bind("PrimaryEntity") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField Visible="true" HeaderText="Durum Açiklamasi">
                    <ItemTemplate>
                        <asp:Label ID="labelWorkFlowStaus" runat="server" Text='<%#  GetStatusCodeText(DataBinder.Eval(Container.DataItem,"StatusCode"))%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnWorkFLow" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

我的gridview分页代码

    WorkFlowDataBind();
    GridWorkFlow.PageIndex = e.NewPageIndex;
    GridWorkFlow.DataBind();

我的第三个按钮代码

    string userQueryId = GetUserQueryId();
    string userqueryName = GetUserQueryName();
    string workFlowId = GetWorkFlowId();
    string primaryEntityName = GetWorkFlowPrimaryEntity();
    GetWorkFlowName();

单击加载网格视图时我的第一个和第二个按钮

    Datatable dtUserQuery=GetDataTable();
    GridUserQuery.DataSource = dtUserQuery;
    GridUserQuery.DataBind()

我该如何解决。

【问题讨论】:

  • 亚当我用我的代码编辑我的帖子
  • 你能粘贴整个代码吗?

标签: asp.net ajax updatepanel


【解决方案1】:

逻辑是..如果您在同一页面中有一个或多个更新面板,那么所有更新面板的属性应该相同,例如更新面板数据是否相互依赖

Update Mode : Always
EnableViewState : true(if you are using it)

或者您可以在模式为条件时显式更新更新面板

假设您有两个更新面板,例如 up1 和 up2。 您已将标签放置在 up1 中,并将其他表单或按钮放置在 up2 中。 现在在 up2 中的点击事件上,放置在 up1 中的标签应该在不加载整个页面的情况下更新。设置以下东西

  1. 设置 EnableParitialRendering ='True'(脚本管理器)

  2. 设置更新模式:Conditional(up1)

  3. 设置更新模式:始终 (up2)。所有设置在这里完成。点击 up2 中的一个按钮,做你的工作并调用 up1.Update();就是这样。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    相关资源
    最近更新 更多