So, here is my, hopefully, unique back of this common problem.
I make my request, get my objects, then pass the object to the form, where it fills the form with data from the object (this is not passed by reference).
Then I edit the values of the object that was requested (via the form), and then returns a new object built from the values in the form.
Then I want to update this in the database. Attach does nothing (running, but not updating). SubmitChanges also does nothing (and both do nothing when shared).
What am I missing?
Update: here is the code I'm using:
_dataMap = new DataMapDataContext();
_addresses = _dataMap.AddressItems
.Where(address => address.InsertUserName == _currentUser.Name).ToList();
public void EditButtonClick()
{
using (AddAddressForm form = new AddAddressForm(_addresses[_currentAddress]))
{
form.Text = "Edit Address";
if (DialogResult.OK == form.ShowDialog())
{
_addresses[_currentAddress] = form.Item;
_dataMap.SubmitChanges();
DisplayItem();
}
}
}
source
share