Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Changing the value in a DataGridComboBox doesn't save

$
0
0

I'm working with the DataGridComboBox for the first time, and found some odd behavior. I'm using entity framework as the source. It is binding fine to the backend data and displaying it fine. I decided, in testing, to change the value of the data associated with the combo box, to another value. When I did a red border appeared around the cell of the DataGridComboBox, so I know something was wrong, but I'm not sure what. I went ahead and tried saving the data. It "saved" without error, but when I reopened the window looking at the same data, the change I made wasn't reflected. Inserting and deleting data works fine, but modifying data doesn't save. What am I doing wrong?

Here's the relevant XAML:

<DataGrid x:Name="aSIIncomeLast30DataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}"
		  Margin="25,80,42,80" RowDetailsVisibilityMode="VisibleWhenSelected" AlternatingRowBackground="Gainsboro"><DataGrid.Columns><DataGridTextColumn x:Name="clientNumberColumn" Binding="{Binding ClientNumber}" Header="Client Number" Width="SizeToHeader" IsReadOnly="True"/><DataGridTextColumn x:Name="caseNumberColumn" Binding="{Binding CaseNumber}" Header="Case Number" Width="SizeToHeader" IsReadOnly="True"/><DataGridTextColumn x:Name="followupColumn" Binding="{Binding Followup}" Header="Followup" Width="SizeToHeader" IsReadOnly="True"/><DataGridComboBoxColumn x:Name="incomeTypeColumn" SelectedValueBinding="{Binding IncomeType}"
								ItemsSource="{Binding Source={StaticResource aSICodesIncomeTypeViewSource}}"
								DisplayMemberPath="IncomeTypeDesc" SelectedValuePath="IncomeType"
								Header="Income Type" Width="SizeToCells"/><DataGridTemplateColumn x:Name="amountEarnedColumn" Header="Amount Earned" Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><telerik:RadMaskedCurrencyInput Value="{Binding AmountEarned}" Mask="c5.2" Placeholder=" " /></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><telerik:RadMaskedCurrencyInput Value="{Binding AmountEarned}" /></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid><Button x:Name="btnSave" Content="Save" HorizontalAlignment="Left" Margin="277,334,0,0" VerticalAlignment="Top" Width="75" ToolTip="Just saves locally" Click="btnSave_Click"/>

And here's the code behind for the saving of the data:

private void btnSave_Click(object sender, RoutedEventArgs e)
{
	try
	{
		asiContext.SaveChanges();
		MessageBox.Show("Saved");
	}
	catch (Exception ex)
	{
		MessageBox.Show(ex.Message);
	}
}


Rod


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>