Update gridview without refreshing the page
14,468
Solution 1
<asp:GridView ID="GridView1" runat="server" EnableViewState="false">
</asp:GridView>
BY DOING enableviewstate=”false” we make sure we are seeing updated data.!
Solution 2
Try using an UpdatePanel
<asp:UpdatePanel ID="UpdtPnlForGrdVw" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ...></asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
As we set UpdateMode to Conditional we mean that
We will be updating the content of the
UpdtPnlForGrdVw
manually.
After binding data to the gridview use
UpdtPnlForGrdVw.Update()
to update the contents of the updatepanel which in your condition will be the gridview.
You can also do this with JavaScript, check https://stackoverflow.com/a/6177348/647884, remember you won't need the opener in your case if you try the solution in the link.
Solution 3
Try following code:
GridView1.DataBind();
Author by
Manthan Shah
Updated on November 22, 2022Comments
-
Manthan Shah over 1 year
Right now i m redirecting to same page for showing updated values in grid view. but i want to do that staying on the same page.I am using List as DataSource and not any Database.
-
Tim Schmelter over 11 yearsWhy don't you modify the DataSource of the GridView accordingly and call
grid.DataBind()
. Apart from that, show what you've tried. -
Ravi Vanapalli over 11 years@manthan9311 please do up vote correct answers
-
-
Tim Schmelter over 11 yearsThat is simply wrong. TRULY Understanding ViewState
-
V.J. over 11 yearsthanks. i was using collections so it was possible. but in case of database i should use updatepanel. thanks 4 correction. Tim.
-
Tim Schmelter over 11 yearsThis is not even a comment (although it is a step in the right direction).
-
Tim Schmelter over 11 yearsOP hasn't mentioned that he wants to use ajax or that the flicker is the issue.
-
Adil Mammadov over 11 yearsBut it can be helpful to someone else who will read this "comment" )
-
Bastardo over 11 years@TimSchmelter Well Tim, you are right but it is still a solution isn't it? Plus I am just suggesting things he doesn't have to mention using ajax, right?
-
Admin over 11 yearsHow can we do paging when using gridview in updatepanel as it is not supported for details check following link : Update Panel Control