473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reloading GridView contents

How can I refresh the contents of a gridview that's on a different
form than the one I'm using? The gridview is bound to a datasource,
and in this other form I'm writing to the database that this
datasource is created by. I have to manually close and restart my app
to see the updated contents in the gridview. Any suggestions are
appreciated.

Nov 14 '07 #1
4 4877
Consider (among many other solutions) making a public static Method
"RefreshData" on the form you need to have refreshed. You can then make a
call to this method from the other form, eg. MyOtherForm.RefreshData()
This would get the latest data from the database and then rebind the Grid.

--Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Chris" wrote:
How can I refresh the contents of a gridview that's on a different
form than the one I'm using? The gridview is bound to a datasource,
and in this other form I'm writing to the database that this
datasource is created by. I have to manually close and restart my app
to see the updated contents in the gridview. Any suggestions are
appreciated.

Nov 14 '07 #2
Ok, that makes sense. And in that method, the actual command to
refresh the gridview is 'gridview.refresh()' ? Or do I need to re
bind the datasource? And if so, how?

Thanks!!

On Nov 14, 9:40 am, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
Consider (among many other solutions) making a public static Method
"RefreshData" on the form you need to have refreshed. You can then make a
call to this method from the other form, eg. MyOtherForm.RefreshData()
This would get the latest data from the database and then rebind the Grid.

--Peterhttp://www.eggheadcafe.com
unBlog:http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Chris" wrote:
How can I refresh the contents of a gridview that's on a different
form than the one I'm using? The gridview is bound to a datasource,
and in this other form I'm writing to the database that this
datasource is created by. I have to manually close and restart my app
to see the updated contents in the gridview. Any suggestions are
appreciated.

Nov 14 '07 #3
You would need to re-get the data just as if for the first time, and
re-assign it to the DataSource property.
--
--Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Chris" wrote:
Ok, that makes sense. And in that method, the actual command to
refresh the gridview is 'gridview.refresh()' ? Or do I need to re
bind the datasource? And if so, how?

Thanks!!

On Nov 14, 9:40 am, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
Consider (among many other solutions) making a public static Method
"RefreshData" on the form you need to have refreshed. You can then make a
call to this method from the other form, eg. MyOtherForm.RefreshData()
This would get the latest data from the database and then rebind the Grid.

--Peterhttp://www.eggheadcafe.com
unBlog:http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Chris" wrote:
How can I refresh the contents of a gridview that's on a different
form than the one I'm using? The gridview is bound to a datasource,
and in this other form I'm writing to the database that this
datasource is created by. I have to manually close and restart my app
to see the updated contents in the gridview. Any suggestions are
appreciated.


Nov 14 '07 #4
Ok, so I have this public function on the same form as the gridview,
that basically sets its datasource to null, and rebinds it after
running a query. If I call that function, from within the same form,
the gridview refreshes just fine. But if I call that public function
from a different form, it doesn't do anything. Not sure where to go
from here...

On Nov 14, 2:31 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
You would need to re-get the data just as if for the first time, and
re-assign it to the DataSource property.
--
--Peterhttp://www.eggheadcafe.com
unBlog:http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Chris" wrote:
Ok, that makes sense. And in that method, the actual command to
refresh the gridview is 'gridview.refresh()' ? Or do I need to re
bind the datasource? And if so, how?
Thanks!!
On Nov 14, 9:40 am, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
Consider (among many other solutions) making a public static Method
"RefreshData" on the form you need to have refreshed. You can then make a
call to this method from the other form, eg. MyOtherForm.RefreshData()
This would get the latest data from the database and then rebind the Grid.
--Peterhttp://www.eggheadcafe.com
unBlog:http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Chris" wrote:
How can I refresh the contents of a gridview that's on a different
form than the one I'm using? The gridview is bound to a datasource,
and in this other form I'm writing to the database that this
datasource is created by. I have to manually close and restart my app
to see the updated contents in the gridview. Any suggestions are
appreciated.
Nov 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
by: Snolly | last post by:
Hi all, Here is my issue. I have a web page (lets call it page1) with an iframe in it that then opens a pop-up window (page2). The pop-up window is used to edit some data that was loaded into...
3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
1
by: | last post by:
I'm wondering if it's possible, outside of the declaration of an ASP.NET 2.0 GridView, to programmatically style individual columns. For example, I might want to make the text in a particular...
4
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. ...
1
by: servernet1997 | last post by:
I have a gridview with 4 columns. Two of the columns are read-only and two are editable. The two editable columns are listboxes leveraging an ObjectDataSource. The first listbox is populated from a...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
2
by: tonymcq | last post by:
I am very new to VB.net / ASP and have spent hours and hours trying to solve what must be a simple problem - hopefully someone can point me in the right direction. I have a gridview bound to an...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.