Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
920 views
in Technique[技术] by (71.8m points)

c# - Using GridView inside UpdatePanel

I have an Updatepanel and Gridview inside it.

<asp:UpdatePanel ID="uplPanel" UpdateMode="Conditional" runat="server" OnLoad="uplPanel_Load">
<ContentTemplate>
 <asp:GridView ID="gvPrList" runat="server" AutoGenerateColumns="false" AllowPaging="false"
       AllowSorting="false" CssClass="list-table" HeaderStyle-CssClass="header">
       <Columns>
     <ItemTemplate>
               <asp:Button ID="btnEdit" runat="server" Text="Edit" CssClass="button save" OnCommand="onPrItemCmd"
                   CommandName="editRow" CommandArgument='<%#Bind("ID") %>' Style="width: 80px" />
               <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="button save" OnCommand="onPrItemCmd"
                   CommandName="deleteRow" CommandArgument='<%#Bind("ID") %>' Style="width: 80px" />
           </ItemTemplate>
       </asp:TemplateField>
   </Columns>

When I click on my buttons inside the Griview, it does not fire the events. Any idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to add OnCommand event of GridView and then handle that inside that event like this:

OnRowCommand="gvPrList_OnRowCommand" 

or alternatively add a click event for the individual button and then handle in the code behind file:

<asp:Button ID="btnEdit" runat="server" OnClick="btnEdit_Click" Text="Edit" CssClass="button save"
                   OnCommand="onPrItemCmd" CommandName="editRow" CommandArgument='<%#Bind("ID") %>' Style="width: 80px" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...