Reputation: 41
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?
Upvotes: 0
Views: 15197
Reputation: 92
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>
Upvotes: 1
Reputation: 10115
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?
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
Upvotes: 1