ChrisW
ChrisW

Reputation: 11

DBContext doesn't save changes the first time around

As stated in the title I am trying to save changes. For that I am using an ultragrid that is connected to my database. The weird thing is that if I try to save any change in ultragrid the first time (by pressing the btnSave) it doesn't save the changes, but any subsequent change, after reopening the childform, gets saved. What could be the Problem?

This is my Code

private Context _context;

public ChildForm()
{
    InitializeComponent();
    _context = new Context();
}

private void Module_Load(object sender, EventArgs e)
{
    _context.Module.Load();
    ModuleBindingSource.DataSource = _context.Module.Local.ToBindingList();
}

private void btnSave_Click(object sender, EventArgs e)
{
    if (ultraGrid.ActiveCell.Activated)
    {
        ultraGrid1.PerformAction(
            Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
    }
    _context.SaveChanges();
    _context.Dispose();
    Close();
}

Upvotes: 1

Views: 47

Answers (0)

Related Questions