我在代码隐藏中有以下直接事件处理程序:
public void changeBlock(string blockname)
{
IntraNetEntities ent = new IntraNetEntities();
var query = from x in ent.Mailings_blocked where x.blocked == blockname select x;
if (query.Count() == 0)
{
Mailings_blocked add = new Mailings_blocked();
add.blocked = blockname;
ent.AddToMailings_blocked(add);
}
else
{
Mailings_blocked del = ent.Mailings_blocked.Single(c => c.blocked == blockname);
ent.DeleteObject(del);
}
ent.SaveChanges();
updateStore();
Grid_Business.RefreshView();
Grid_Mailing.RefreshView();
}
但是当触发事件时,数据库会更新,就像存储一样,但是 RefreshView() 没有正确执行。当单击同一实用程序的任何其他按钮(这是一个 rowCommand)时,视图会更新到之前单击所需的状态。