I have bindingList bound to TextBoxes. When I enter new value in textboxes and press save button the value from last Textbox dosen't save in database. But when I pressed Tab key before save button every values from texboxes were saved. How resolve this problem with unsaved last value?

....

BindingList<Zamo> myList;
pg = new PGEntities();
var query = (from zam in pg.Zamo where zam.ID == rekord.ID).Take(1);
myList = new BindingList<Zamo>(query.ToList());
zamoBindingSource.DataSource = myList;   

....

private void SaveButton()
{
    pg.SaveChanges();
}

This occurs only when I save by button in BindingNavigation.

有帮助吗?

解决方案

When you press the tab key it is getting saved? that probably means the saveButton event is reading the text before the entered text is considered. Try to lose focus on the textbox, then save.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top