2010-08-04 53 views
0

我使用LinqDataSource和gridview控件和我的分頁/排序工作正常,但是當我添加<asp:UpdatePanel比它不工作,下面是我的.aspx頁面,我不確定我很想念......頁面/排序不工作<asp:UpdatePanel

<%@ 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 &nbsp;</div> 
        </PagerTemplate> 
       </asp:GridView>      
     </ContentTemplate> 
    </asp:UpdatePanel> 
    </div> 
</asp:Content> 
+1

我看你的UpdateMode =條件和ChildrenAsTriggers = false爲您的UpdatePanel。難道這是因爲這兩個屬性的組合,Paging/Sorting回發事件根本沒有被解僱。你可以試試ChildrenAsTriggers = true,看看它是否只是爲了驗證這是否確實導致了問題? – InSane 2010-08-04 02:17:49

+0

+1感謝和現在的工作,不知道我是如何錯過的。 – 2010-08-04 15:22:06

回答

1

既然你有ChildrenAsTriggers="false"只設置爲AsyncPostBackTrigger會導致在UpdatePanel的更新的控件。

爲什麼你需要ChildrenAsTriggers="false"

UpdatePanel.ChildrenAsTriggers Property