以不同的形式更新实体后,我想重新加载网格中的数据,但它似乎没有更新。我使用:
private void LoadData()
{
siparisBindingSource.DataSource = db.Siparis.Include("Kazan").ToList();
}
加载数据。打开对话框后:
private void değiştirToolStripMenuItem_Click(object sender, EventArgs e)
{
Siparis siparis = gridView1.GetFocusedRow() as Siparis;
if (siparis != null)
{
FormSiparisAddEdit siparisAddEdit = new FormSiparisAddEdit {isedit = true, sipID = siparis.ID};
siparisAddEdit.ShowDialog();
LoadData();
}
}
并更改实体,我尝试使用此方法重新加载,但除非我关闭并重新打开表单,否则内容保持不变。我在这里缺少什么?
为答案喝彩,但我现在有另一个问题,因为我已经使数据库短命,我无法获得详细数据,我尝试使用:
private void gridView1_MasterRowGetChildList(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetChildListEventArgs e)
{
Siparis siparis = (Siparis)gridView1.GetRow(e.RowHandle);
using (var db = new Tank_Analizor_DBEntities())
{
db.Siparis.Attach(siparis);
e.ChildList = new BindingSource(siparis, "Kazan");
}
}
但我明白了
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
错误,如果我调试它,子列表会获取详细数据...