Avatar of sepknow
sepknow asked on

How to refresh the datagridview that is data bound after the underlaying storage has changed

I have a datagridview that is bound to a data source.
After inserting a record in a table, how do I refresh the datagridview?
.NET Programming

Avatar of undefined
Last Comment
Munawar Hussain

8/22/2022 - Mon
Nerdwood

Hi sepknow

Use nameOfDataGridView.DataBind() to refresh the data being displayed.

Michael
ASKER
sepknow

Hi Michael,
There is no DataBind method in DataGridView. Is there?
Nerdwood

No, sorry... I've just been having a look for the solution... I'll let you know if I come up with anything!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
sepknow

Thanks.
ASKER CERTIFIED SOLUTION
Jorge Paulino

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Nerdwood

Yep, jpaulino's solution should work.
Munawar Hussain

Hi, if you have datagrid on same form and or in same application where you are updating the underlying datasource then it is simple , just after updating the datastore .. refill the datatable or datasource which you are using to bind with gridView.

but if data is being updated from a different application and you are showing in another application then it would be better to write code in form activate event as well as use a timer which will check the datastore after regular intervals and will keep fresh data available on the gridview.

in case of activate event , as user navigate to another form , you may minimize the form and when user comes back and maximize the form , it will refresh the girdview.

Feel free for any question.
Thanks
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.