开发者

Controls not updating on inserting an Entities object

Hello I have an Entity "Candidate" which is set as a datasource for a GridView and a combobox. When i Update or Delete something, thw datasource i开发者_如何学编程s updated and the gridview and combobox show the changes.

However when i inser a new Entity then the data in the two controls doesnt refresh automatically. i have to close and reopen the form to see the changes.

My code is

AMSEntities objContext =new AMSEntities ();

private void btnInsert_Click(object sender, EventArgs e)

{

Candidate cand1 = new Candidate();

cand1.CandidateName ="Amir";

cand1.CandidateFatherName ="Asdf";

cand1.DOB =DateTime.Now;

objContext.Candidates.AddObject(cand1);

objContext.SaveChanges();

}


Not sure this is an Entity Framework question - seems to be more of an ASP.NET related question. Shouldn't you call gridView.DataBind() after SaveChanges?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜