C# .NET - refresh gridview in asp.net (C# web application)

Asked By kshama parashar on 10-Sep-10 02:36 AM
hi all 

i want to refresh my gridview on button click but i don't want to reload the page only reload the page.
how can i do it?
Sagar P replied to kshama parashar on 10-Sep-10 02:39 AM
You have to use AJAX for that if you dont want to refresh whole page.....

Just take on updatepanel and put your button and gridview in same panel...

And on btton click bind data to gridview again which will refresh data of gridview... and as we have used updatepanel it will only refresh gridview, it will not refresh whole page.....
Kirtan Patel replied to kshama parashar on 10-Sep-10 03:24 AM
you can do this with AJAX Timer Control + Update Panel

Place your GridView inside the Update Panel and Set timer on It this will only update your Gridview (Partial Page Update)

no other controls will be affected .
kshama parashar replied to Kirtan Patel on 10-Sep-10 03:40 AM
thanks for replay 

but i have 2 gridview and two refresh button for both gridview now i want that when i click on first refresh button the first grid will refresh and when i click on second refresh button the second gridview will refresh
Kirtan Patel replied to kshama parashar on 10-Sep-10 04:10 AM

You can use as many Update Panel as you want in your aspx page ..

also its not necessary that you use timer you can fire event in Update panel by any Kind of Control like button also ..

if you are not familiar with Update Panel have a look at below article hope it help you


http://www.codegod.de/WebAppCodeGod/UpdatePanel-and-Triggers-with-ASP-NET-AJAX-AID282.aspx
kshama parashar replied to Kirtan Patel on 10-Sep-10 06:12 AM
thanks its working