subprime
subprime

Reputation: 1215

How can i update DataGridView in c# if Source has changes

i have a Problem with DataGridView in c# and i hope you can help me :) I added a DataGridView to my Application and bind it to DataTable. The DataTable changing the content but the DataGridView doesnt display it... How can i change this ? Thanks

Upvotes: 1

Views: 15101

Answers (5)

sassouki
sassouki

Reputation: 1

// clear your dataset
this.dataSet1.Clear();
// refill you dataset
this.dataSet1.ReadXml("data.xml");

Upvotes: -2

jasom
jasom

Reputation: 1

You need use

this.TableAdapter1.Fill(this.DataSet1.zakaznici);

That is usable for me. Try it

Upvotes: 0

David
David

Reputation: 73564

Is the data changing at the source, or within the application?

If the data is changing at the source, then I think the issue may be that .Net by default supports a disconnected data paradigm which is different from using a permanently connected model. Once the data is retrieved from the server, the client is no longer connected unless you go and get the data again. For example, if you're using a TableAdapter, you'd have to periodically call the DataAdapter.Fill() command to retrieve the data from the server.

If the data is changing in your app based on user interaction, then possibly DataDable.AcceptChanges() followed by Application.DoEvents()?

Upvotes: 4

buricea
buricea

Reputation:

grid.dataBind()

Upvotes: 0

Khadaji
Khadaji

Reputation: 2167

Did you try DataGridView.Refresh()?

Upvotes: 1

Related Questions