我在更新到数据库后重新加载数据时遇到一些问题我从表单加载BindGrid()事件加载我的gridview我在这里包含了我的代码。
我的Delcarations如下我在这里尝试过所有东西但是不能强迫它刷新网格
Dim dbContext As New R3Delivery
Dim threeContext As New skechersDeliveryEntities1
Dim bs As New BindingSource
Private Sub frmConfirmDeliverys_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
BindGrid()
dgDeliverys.Columns(0).ReadOnly = True
dgDeliverys.Columns(1).ReadOnly = True
dgDeliverys.Columns(2).ReadOnly = True
End Sub
Public Sub BindGrid()
Dim cfglocation As Int16
cfglocation = cfb.StoreLocation
bs.DataSource = (From u In threeContext.R3Delivery Where u.isprocessed = True AndAlso u.location = 1
Select u)
bs.ResetBindings(True)
dgDeliverys.DataSource = bs
End Sub
我的保存按钮如下
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
threeContext.SaveChanges()
BindGrid()
End Sub
我认为我应该展示我的表单声明以及上面的代码在我的编辑表单中,以下是我的来自
Dim frmConfirmDeliverys As New frmConfirmDeliverys
frmConfirmDeliverys.ShowInTaskbar = False
frmConfirmDeliverys.ShowDialog()
答案 0 :(得分:0)
dgDeliverys.Datasource=Nothing
dgDeliverys.DataSource = bs
或
dgDeliverys.Refresh
也像 jmcilhinney 所说,检查查询是否返回了您期望的数据。