使用更新面板时,Asp.net嵌套Gridview不会刷新

时间:2017-10-06 21:00:02

标签: asp.net gridview nested updatepanel

请查看代码中的错误,我看到事件被触发并将其带到后面的代码但是嵌套的GridView在排序事件上没有刷新。提前感谢您的帮助!

<asp:UpdatePanel ID="upaccount" runat="server" ChildrenAsTriggers="false" UpdateMode="conditional">
    <ContentTemplate>
                <asp:GridView ID="gvSupplierList" runat="server"
                  AutoGenerateColumns="false"
                    EmptyDataText="No Record found"
                    AllowPaging="true"
                    RepeatDirection="Vertical" Width="100%"
                    DataKeyNames="supplierid" OnRowDataBound="gvSupplierList_RowDataBound">
                    <RowStyle HorizontalAlign="left" />
                    <Columns>
                        <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="3%" HeaderStyle-ForeColor="White">
                            <ItemTemplate>
                                <img id="imgexp" runat="server" alt="" style="cursor: pointer" src="plus.png" />
                                <div style="display: none;">
                                    <div style="height: 350px; overflow: scroll">
                                        <asp:UpdatePanel ID="upcustomer" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                                            <ContentTemplate>
                                                <asp:GridView ID="gvCustomerList" runat="server" AutoGenerateColumns="false" CssClass="ChildGrid"
                                                    OnSorting="gvCustomerList_Sorting" AllowSorting="true"
                                                    HeaderStyle-BackColor="WhiteSmoke" Width="100%" Style="height: 400px; overflow: auto;"
                                                    DataKeyNames="cmp_wwn">
                                                    <Columns>
                                                        <asp:BoundField DataField="KeyAccount" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%" HeaderText="2017 Key" />
                                                    </Columns>
                                                </asp:GridView>
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvCustomerList" EventName="Sorting" />
                                            </Triggers>
                                        </asp:UpdatePanel>

                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSave1" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

下面添加了代码,请检查。

Protected Sub gvCustomerList_Sorting(sender As Object, e As GridViewSortEventArgs)

    Dim sortExpression As String = e.SortExpression
    Dim direction As String = String.Empty


    If (SortDirection = SortDirection.Ascending) Then
        SortDirection = SortDirection.Descending
        direction = " DESC"
    Else
        SortDirection = SortDirection.Ascending
        direction = " ASC"
    End If


    Dim gvCustomerList As GridView = CType(sender, GridView)
    Dim supplier As String = DirectCast((gvCustomerList.Parent.Parent.FindControl("hdnsupplier")), System.Web.UI.WebControls.HiddenField).Value
    Dim dt As DataTable = GetCustomer(supplier)
    dt.DefaultView.Sort = sortExpression + direction
    gvCustomerList.DataSource = dt
    gvCustomerList.DataBind()

    Dim panel As UpdatePanel = DirectCast((gvCustomerList.Parent.Parent.FindControl("upcustomer")), System.Web.UI.UpdatePanel)
    panel.Update()


End Sub

0 个答案:

没有答案