简体   繁体   English

asp.net中用于gridview的Ajax更新面板

[英]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. 我有一个带有手风琴控制的页面,其中我有2个网格放置在两个框架中。 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' 错误:::在UpdatePanel'UpdatePanel3'中找不到ID为'btnAdd'的控件作为触发器

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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