So, I have a table with 3 columns (location, onhand, committed). When a user clicks on a particular row, a pop window is displayed which allows a user to change the value of "committed". Hence, when the pop is closed, I want to see the updated value in the table. However, that is not the case although the value has already been updated in the db. Can someone tell me where am I making a mistake in the code?
I followed this answer but it didn't help me.
Her'es my View Code:
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" Header="OnHand" Binding="{Binding Path= OnHand,Mode = TwoWay,UpdateSourceTrigger=PropertyChanged }" />
</DataGrid.Columns>
Here's how I populate the grid:
foreach (var item in inventoryList)
{
items.Add(new InventoryDto { location = item.location.Name, OnHand = item.OnHand.ToString(), committed = item.committed.ToString() });
}
InventoryDataGrid.ItemsSource = items;
Here's the class:
class InventoryDto : INotifyPropertyChanged
{
public string location { get; set; }
public string onHand { get; set; }
public string committed { get; set; }
public InventoryDto()
{
}
public InventoryDto(string location, string OnHand, string committed, string productId)
{
this.location = location;
this.onHand = OnHand;
this.committed = committed;
}
public string OnHand
{
get
{
return onHand;
}
set
{
onHand = value;
OnPropertyChanged("OnHand");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}