2014-03-13 29 views
0

我有一個頁面與手風琴控制,其中我有2個網格放置在兩個框架。我已經在網格中提供了驗證來插入一個新行。在asp.net中的gridview的Ajax更新面板

但是當我點擊更新一個網格時,兩個網格都得到驗證。爲了避免這種情況,我在更新面板中保留了這個網格,我將更新按鈕保存在觸發器內,如下面的代碼所示。但是它在運行應用程序時拋出一個錯誤。

ERROR::: A control with ID 'btnAdd' could not be found for the trigger in UpdatePanel 'UpdatePanel3'

<asp:UpdatePanel ID="UpdatePanel3" 
        UpdateMode="Conditional" 
        runat="server"> 
        <Triggers> 
         <asp:AsyncPostBackTrigger ControlID="btnAdd" /> 
        </Triggers> 
        <ContentTemplate> 
         <asp:GridView ID="gvw_Authority" DataKeyNames="ID" runat="server" 
          AutoGenerateColumns="false" CssClass="Gridview" HeaderStyle-BackColor="#61A6F8" 
          ShowFooter="true" HeaderStyle-Font-Bold="true" HeaderStyle-ForeColor="White" 
          OnRowCancelingEdit="gvw_RowCancelingEdit" 
          OnRowDeleting="gvw_RowDeleting" OnRowEditing="gvw_RowEditing" 
          OnRowCommand="gvw_RowCommand"> 
          <Columns> 

.... 

<asp:TemplateField> 
            <EditItemTemplate> 
             <asp:ImageButton ID="imgbtnUpdate" runat="server" CommandName="Update" ImageUrl="~/Images/accent.png" ToolTip="Update" Height="20px" Width="20px" /> 
             <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/Images/bullet.png" ToolTip="Cancel" Height="20px" Width="20px" /> 
            </EditItemTemplate> 
            <ItemTemplate> 
             <asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/Images/heroAccent.png" ToolTip="Edit" Height="20px" Width="20px" /> 
             <asp:ImageButton ID="imgbtnDelete" CommandName="Delete" Text="Edit" runat="server" ImageUrl="~/Images/orderedList0.png" ToolTip="Delete" Height="20px" Width="20px" /> 
            </ItemTemplate> 
            <FooterTemplate> 
             <asp:LinkButton ID="btnAdd" runat="server" ImageUrl="~/Images/orderedlList1.png" CommandName="AddNew" Width="30px" Height="30px" ToolTip="Add new User" ValidationGroup="validaiton1"></asp:LinkButton> 
            </FooterTemplate> 
           </asp:TemplateField> 
          </Columns> 
         </asp:GridView> 

請建議的替代解決方案單獨更新此網格。

在此先感謝。

回答

0

我自己找到了解決方案。請在下面找到它。我們必須圍繞鏈接按鈕保留其他更新面板。

<FooterTemplate> 
    <asp:UpdatePanel ID="UpdatePanel3" 
        UpdateMode="Conditional" 
        runat="server"> 
     <ContentTemplate> 
      <asp:LinkButton ID="btnAdd" runat="server" Text="Add" CommandName="AddNew" Width="30px" Height="30px" ToolTip="Add new User" ValidationGroup="validaiton1"></asp:LinkButton> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</FooterTemplate>