views:

1018

answers:

2

Hi Guys,

I have two Datagridviews in a tab and the datasource of the second grid is based on the row selection in first grid. The problem is I cannot get the grid to refresh after some values have been inserted or updated in the prior tabs. It works fine if I click on the row but it is not working if I select the row programmatically (i.e. first row). I have tried the following but it failed to refresh.
daProgram.ClearBeforeFill = true
daProgram.fill(dsProgram)
bsProgram.ResetBindings(true) -- binding source also tried false
'also tried
'dgvProgram.DataSource=nothing
'and
'dgvProgram.DataBindings.clear()
'Nothing works :-(
dgvProgram.DataSource=bsProgram -- rebinding the control

I would really appreciate if anyone could help me out in this.

Thanks,
Raja

A: 

I have read a few things about this, and too found ResetBindings not to work.

If you're using Table Adapters, just call the fill method (the method that auto gets added in to your Form Load event).

I've read things that say you shouldn't call Fill. I see no reason why not. It simply re-queries the data, which is exactly what a refresh should do.

Me.YourTableAdapter.Fill(Me.YourDataSet.YourDataTable)