I have a binding navigator which I am using to add/edit items. The problem I'm having is when I click the save button (button I added to the toolbar) my bindings dont seem to have taken effect. This code loads and binds my data.
private void CompanyForm_Load(object sender, EventArgs e)
{
// Loads all of the companies
companies = new BindingList<Company>(PersistenceManager.Instance.RetrieveAll<Company>()));
companies.AllowNew = true;
companies.AllowEdit = true;
bindingSource.DataSource = companies;
// Add our bindings
companyIdTextBox.DataBindings.Add("Text", companies, "Id");
companyNameTextBox.DataBindings.Add("Text", companies, "Name");
}
And this code is run when the save button is clicked:
private void toolStripSaveButton_Click(object sender, EventArgs e)
{
// If we have no binding source, then we cannot save
if (null == bindingSource.Current)
{
return;
}
Company company = bindingSource.Current as Company;
// Save our company
PersistenceManager.Instance.Save<Company>(company);
}
The problem is when I click the save button, the current item is never updated with the data from the inputs.
Am I just missing something stupid?