I am running into an issue with refreshing data on a page after doing an update through WCF RIA Services.
I have a ComboBox and a Button on a page. The user chooses an item from the ComboBox, and then clicks the Button. This does a soft delete of the item in the database(setting "Active" = false). However, I would like for it to be removed from the ComboBox after the updated has completed. This is where my problem is.
InventorySystemDomainContext context = new InventorySystemDomainContext();
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
Cigarette c = cboCigarette.SelectedItem as Cigarette;
c.Active = false;
SubmitOperation so = context.SubmitChanges();
so.Completed += delegate (object s, EventArgs es)
{
LoadComboBox();
}
}
private void LoadComboBox()
{
cboCigarettes.DataSource = null;
cboCigarettes.DataSource = context.Cigarettes;
context.Load(context.GetCigarettesQuery());
}
When the Delete button is clicked, all the code runs. However, the deleted item is still in the ComboBox(even though the record has been updated in the database). If I refresh the page, the item is gone from the ComboBox.
Any ideas?
PS: I wrote this code from memory since I don't have the code with me. So I may have forgotten a line, but I think I got all the relevant lines.