我正在使用LinqDataSource和gridview控件,我的分页/排序工作正常但是当我添加<asp:UpdatePanel
而不是它不工作时,下面是我的.aspx页面,我不知道我错过了什么...
<%@ Page Language="C#" MasterPageFile="~/MasterPage/MAIN.Master" AutoEventWireup="true" CodeBehind="ContPage.aspx.cs" Inherits="ContPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMaster" runat="server">
<div class="contentContainer">
<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource_Selecting"
ContextTypeName="MyDataContextDataContext" AutoPage="true" AutoSort="true">
</asp:LinqDataSource>
<asp:UpdatePanel ID="up_gv1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnReset" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ddlFilterResultBy" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:GridView runat="server" ID="gv" AutoGenerateColumns="False"
CssClass="gv" DataSourceID="LinqDataSource1" Width="880px" AllowPaging="true" AllowSorting="true" DataKeyNames="Id" OnRowDataBound="gvRowDataBound" PageSize="15">
<PagerSettings Visible="true" Position="Bottom" />
<EmptyDataTemplate>No Inquiries</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="InquiryID" Visible="false" />
<asp:TemplateField HeaderText="Date" SortExpression="insertDate">
</asp:TemplateField>
<asp:TemplateField HeaderText="" SortExpression="">
</asp:TemplateField>
<asp:TemplateField HeaderText="Subject" SortExpression="Subject">
<ItemTemplate>
<a href='Edit.aspx?InqId=<%# Eval("Id") %>'>
<%# Eval("Subject")%>
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Officer" SortExpression="Name">
<ItemTemplate>
<asp:Label ID="lblOfficer" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" SortExpression="ReporterInquiryStatusDesc">
<ItemTemplate>
<asp:DropDownList ID="ddStatus" runat="server" DataSourceID="ObjectDataSource1" DataTextField="Name" AppendDataBoundItems="true" DataValueField="Id" SelectedValue='<%# Eval("StatusId")%>'>
<asp:ListItem Text="" Value="0" />
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetStatusList" TypeName="My_DAL.Status_LookupRepository" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" SortExpression="">
<ItemTemplate>
<asp:Button ID="btnSaveRowStatus" runat="server" OnClick="btn_SaveRowStatus" Text="Save" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerTemplate>
<div style="float: left; margin-left: 7px; line-height: 22px;">
<div style="float: left;">
<asp:ImageButton CommandName="Page" CommandArgument="First" ToolTip="First Page" runat="server" ID="PagerFirstButton" />
<asp:ImageButton ID="PagerPrevButton" CommandName="Page" CommandArgument="Prev" ToolTip="Previous Page" runat="server" />
</div>
<div style="float: left;">
<div class="pagerNumber">
<asp:LinkButton runat="server" ID="NumericPager1" CommandArgument="1" Text="1" CommandName="Page" />
</div>
<div class="pagerNumber">
<asp:LinkButton runat="server" ID="NumericPager2" CommandArgument="2" Text="2" CommandName="Page" />
</div>
<div class="pagerNumber">
<asp:LinkButton runat="server" ID="NumericPager3" CommandArgument="3" Text="3" CommandName="Page" />
</div>
<div class="pagerNumber">
<asp:LinkButton runat="server" ID="NumericPager4" CommandArgument="4" Text="4" CommandName="Page" />
</div>
<div class="pagerNumber">
<asp:LinkButton runat="server" ID="NumericPager5" CommandArgument="5" Text="5" CommandName="Page" />
</div>
</div>
<div style="float: left;">
<asp:ImageButton ID="PagerNextButton" CommandName="Page" CommandArgument="Next" ToolTip="Next Page" runat="server" />
<asp:ImageButton ID="PagerLastButton" CommandName="Page" CommandArgument="Last" ToolTip="Last Page" runat="server" />
</div>
</div>
<div class="gridCount" runat="server" id="divGridCount">
<b>1</b> Items Found </div>
</PagerTemplate>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
答案 0 :(得分:1)
由于您只有ChildrenAsTriggers="false"
,因此设置为AsyncPostBackTrigger的控件将导致更新UpdatePanel。
为什么需要ChildrenAsTriggers="false"
?