2014-03-14 44 views
0

我只是想添加網格視圖更新面板快速排序和分頁請求已經完成。和我的網格視圖工作正常。在這裏,我只想補充一個觸發像一個鏈接按鈕,但它給了我運行時間錯誤,如:如何添加網格視圖更新面板

A control with ID 'lbut_category' i set as AsyncPostBackTrigger 

這裏是我設計的看法:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
     <ContentTemplate> 
      <asp:GridView ID="GV_ViewCategories" runat="server" AllowPaging="True" 
      AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
      GridLines="None" Width="100%" 
      ondatabound="GV_ViewCategories_DataBound" 
      onpageindexchanging="GV_ViewCategories_PageIndexChanging" 
      onprerender="GV_ViewCategories_PreRender" 
      onrowcommand="GV_ViewCategories_RowCommand" 
      onrowdatabound="GV_ViewCategories_RowDataBound" 
      onsorting="GV_ViewCategories_Sorting" DataKeyNames="Id"> 
      <RowStyle CssClass="grid1" HorizontalAlign="Left" /> 
      <Columns> 
       <asp:TemplateField> 
        <HeaderStyle CssClass="headinglist_bg" /> 
       </asp:TemplateField> 
       <asp:TemplateField HeaderText="Category Name" SortExpression="CategoryName"> 
        <HeaderStyle CssClass="headinglist_bg" /> 
        <ItemTemplate> 
         <asp:LinkButton ID="lbut_category" runat="server" 
          CommandArgument='<%# Eval("Id") %>' CommandName="View" 
          Text='<%# Bind("CategoryName") %>'></asp:LinkButton> 
        </ItemTemplate> 
        <HeaderTemplate> 
         <asp:LinkButton ID="lbut_sortname" runat="server" 
          CommandArgument="CategoryName" CommandName="Sort" CssClass="normaltext" 
          Font-Bold="true" Text="Category Name"></asp:LinkButton> 
         <asp:PlaceHolder ID="placeholdercategory" runat="server"></asp:PlaceHolder> 
        </HeaderTemplate> 
        <ItemStyle CssClass="quicklink" /> 
       </asp:TemplateField> 
      </Columns> 
      <EmptyDataRowStyle BorderWidth="0px" Width="0px" /> 
      <EmptyDataTemplate> 
       <asp:Label ID="Label2" runat="server" ForeColor="Red" 
        Text="No Records are found"></asp:Label> 
      </EmptyDataTemplate> 
      <PagerStyle CssClass="pager" HorizontalAlign="Center" VerticalAlign="Middle" /> 
      <PagerTemplate> 
       <table> 
        <tr> 
         <td> 
          <asp:ImageButton ID="ImageButton1" runat="server" 
           AlternateText="Go to First Page" CommandArgument="First" CommandName="Page" 
           ImageUrl="../images/1330128819_resultset_first.png" /> 
         </td> 
         <td> 
          <asp:ImageButton ID="ImageButton2" runat="server" AlternateText="Previous Page" 
           CommandArgument="Prev" CommandName="Page" 
           ImageUrl="../images/1330128981_resultset_previous.png" /> 
         </td> 
         <td> 
          Page&nbsp;<asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True" 
           OnSelectedIndexChanged="ddlPages_SelectedIndexChanged"> 
          </asp:DropDownList> 
          of 
          <asp:Label ID="lblPageCount" runat="server"></asp:Label> 
         </td> 
         <td> 
          <asp:ImageButton ID="ImageButton3" runat="server" AlternateText="Next Page" 
           CommandArgument="Next" CommandName="Page" 
           ImageUrl="../images/Farm-Fresh_resultset_next.png" /> 
         </td> 
         <td> 
          <asp:ImageButton ID="ImageButton4" runat="server" 
           AlternateText="Go to Last Page" CommandArgument="Last" CommandName="Page" 
           ImageUrl="../images/1330128876_resultset_last.png" /> 
         </td> 
        </tr> 
       </table> 
      </PagerTemplate> 
      <FooterStyle CssClass="pager" VerticalAlign="Bottom" /> 
      <HeaderStyle HorizontalAlign="Left" /> 
     </asp:GridView> 
     </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="GV_ViewCategories" 
        EventName="RowCommand" /> 
      </Triggers> 
     </asp:UpdatePanel> 

以及解決無效的回調後返回參數我設置EnableEventValidation="false"但在這裏我必須雙擊鏈接按鈕,然後它的迴應。

和這裏EnableEventValidation="false"它可能是危險的安全目的。

任何機構都可以解決嗎?

回答

1

設置ChildrenAsTriggers =「true」就足以觸發updatepanel的回發。在這種情況下,您不需要添加PostBackTrigger。 lbut_sort_person_name找不到,因爲它位於不同的命名容器中,即gridview控件的一行。

+0

好吧,我們再試一次,看看我更新的問題。 –