![](/img/trans.png)
[英]ASP.NET GridView in Update Panel and GridView Row.Count
[英]Ajax update panel for gridview in asp.net
我有一個帶有手風琴控制的頁面,其中我有2個網格放置在兩個框架中。 我已經在網格中提供了驗證以插入新行。
但是,當我單擊一個網格的更新時,兩個網格都得到了驗證。 為了避免這種情況,我將這個網格保留在更新面板中,我將更新按鈕保留在觸發器中,如下面的代碼所示。 但是它在運行應用程序時拋出錯誤。
錯誤:::在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>
請提出單獨更新此網格的替代解決方案。
提前致謝。
我自己找到了解決方案。 請在下面找到它。 我們必須在鏈接按鈕周圍保留另一個更新面板。
<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.