3

I'm loading programatically tables from my db model to a DataGrid in my application

Whenever I identify I loaded a "Base" named column, I want to give the user the option whenever he wants to edit this value in the DataGrid to choose a value from a ComboBox

so whenever I identify I found a "Base" column I do this:

for (int i = 1; i < this.main_grid.Columns.Count; i++)
{
    if (this.main_grid.Columns[i].Header.ToString() == "Base")
    {

        var query = from tbl in db.BASES select tbl;
        this.main_grid.Columns.RemoveAt(i);
        DataGridComboBoxColumn dgCmbCol = new DataGridComboBoxColumn();
        dgCmbCol.Header = "Base";
        dgCmbCol.ItemsSource = query.ToList();
        dgCmbCol.DisplayMemberPath = "base_name";
        dgCmbCol.SelectedValuePath = "base_id";
        dgCmbCol.SelectedItemBinding = new Binding("SelectedItem");
        this.main_grid.Columns.Add(dgCmbCol);

        break;
    }
}

the problem is when I call db.SaveChanges() it doesn't save anything. What should I do in a situation like that?

Yael
  • 1,566
  • 3
  • 18
  • 25
user1326293
  • 923
  • 2
  • 9
  • 24

0 Answers0