简体   繁体   中英

Ajax update panel for gridview in asp.net

I have a page with accordian control, where in I have 2 grids to be placed in two frames. I have provided validations in grid to insert a new row.

But when I click on update of one grid, both grids are getting validated. To avoid this I have kept this grid inside update panel, I am keeping my update button inside trigger as shown in code below. But its throwing an error while running the application.

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>

Please suggest an alternative solution for updating this grid alone.

Thanks in advance.

I found the solution myself. Please find it below. We have to keep an other update panel around link button.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM