I'm working on a project where I have to create a page that displays the "health" of a system. I run a query and display the results in a gridview with a red or green icon next to it. This works fine when the page is first loaded. My problem is that I
have a thread that runs a query every 30 minutes and rebinds the gridview but the gridview never refreshes even though the data has changed. How do I get the gridview to display the new results? The databound event never fires a second time even though I
can clearly see that I have received new data. I assume I am missing something simple but I just don't know what. What am I doing wrong?
The thread code is working fine. I have verified that the datatable is being filled with the correct updated information. When I bind it to the gridview the databound event is not fired, there is no postback and the gridview does not get updated.
I hate to break this to you, but web-pages don't have push technology. Refresh of a page can only be done at the initiative of the browser. Making a thread on the server to gather the data will have no effect.
Instead, use a Timer. (And an UpdatePanel to make it look good.) The timer will cause a PostBack. You can determine the new data in the PostBack. The response to the PostBack will be the updated page.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
tefoster
Member
39 Points
26 Posts
Gridview not refreshing after databind
Jun 26, 2010 07:00 AM|LINK
I'm working on a project where I have to create a page that displays the "health" of a system. I run a query and display the results in a gridview with a red or green icon next to it. This works fine when the page is first loaded. My problem is that I have a thread that runs a query every 30 minutes and rebinds the gridview but the gridview never refreshes even though the data has changed. How do I get the gridview to display the new results? The databound event never fires a second time even though I can clearly see that I have received new data. I assume I am missing something simple but I just don't know what. What am I doing wrong?
Thanks,
Tom
GridView Data binding post back
nareshguree2...
Star
11118 Points
1997 Posts
Re: Gridview not refreshing after databind
Jun 26, 2010 12:32 PM|LINK
please check your code again. please check your tread code.
or you can use Tick event of timer to check it is binding grid or not
abhijitaitwa...
Member
2 Points
6 Posts
Re: Gridview not refreshing after databind
Jun 26, 2010 01:18 PM|LINK
First time your gridview binds data perfeclty but not after tick event of timer control.
For bind the gridview after the 30 minutes means after tick event of timer your gridview should be in updatde panel.
If your gridview is not in UpdatePanel then after tick event it will not refresh the grid.
Add your gridview in updatde panel.
http://abhiat.blogspot.com/
tefoster
Member
39 Points
26 Posts
Re: Gridview not refreshing after databind
Jun 26, 2010 07:35 PM|LINK
The thread code is working fine. I have verified that the datatable is being filled with the correct updated information. When I bind it to the gridview the databound event is not fired, there is no postback and the gridview does not get updated.
superguppie
All-Star
48225 Points
8679 Posts
Re: Gridview not refreshing after databind
Jun 28, 2010 02:05 PM|LINK
Instead, use a Timer. (And an UpdatePanel to make it look good.) The timer will cause a PostBack. You can determine the new data in the PostBack. The response to the PostBack will be the updated page.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
tefoster
Member
39 Points
26 Posts
Re: Gridview not refreshing after databind
Jun 28, 2010 07:31 PM|LINK
Thank you for your reply! I didn't think about that approach but I used it and everything is working fine.
Thanks!