简体   繁体   中英

How to prevent postback on gridview

I have a gridview which causes postback when I want to edit a row by clicking on the "edit" in my gridview.

How can I prevent postback upon editing?

use Ajax Update Panel Control, Sample code.. this may helpful to you..


 <asp:UpdatePanel ID="grdUpdatePanel" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
      <asp:GridView ID="grdItemDetails" runat="server">
         -- your code --
         -- your code --
         -- your code --
      </asp:gridView>
   </ContentTemplate>
 </asp:updatePanel>

I assume that In each row you have a edit button. On clicking the edit button you can populate the controls or your Data Entry Form without the postback. example RowBoundEvent of Gridview.


Add the onclick attributes on the edit button click in this event.


References

GridView Row Click Selection via ClientSide Code

How can i made onclick with row index as parameter, on GridView Grid row in asp.net?

c# gridview row click


Use Update Panel to avoid Postbacks for the Gridview events . Make sure to use UpdateMode="Conditional"


References

Remember to set UpdatePanel's UpdateMode to Conditional

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