title: Add ComboBox to WPF DataGrid that pulls from a SQL DataTable
body: <p>I have a WPF program that allows users to edit an SQL data table for part details given a part number. The user enters a part number and I use a table adapter to display their part number details to a data grid using a row filter. I want to be able to take a list of ObservableCollection and bind it to a certain column in my data grid (i.e have a select list drop down list of part types for the part type column). Here is my .cs: </p>
  
  <pre><code>public MainWindow()
          {
              createDropDowns();
              context = new RefreshAppContext();            
              InitializeComponent();
              PartTypeComboBox.ItemsSource = partTypesList;
  #if DEBUG
  #endif
          }
  
          public void findButton_Click(object sender, RoutedEventArgs e)
          {
              var partNumber = inputBox.Text;
              // Searches for part number in db.
              var foundPart = context.RefreshPartTypes.Where(x =&gt; x.PartNumber == partNumber).ToList();
              if (!foundPart.Any() == true)
              {
                  MessageBox.Show("Part not found. Please try another number.");
              }
              else
              {
                  // Adapter used to fill DT with info from DB based on query(ies).
                  adapter_PT.Fill(table_PT);
                  DataView dv = table_PT.DefaultView;
                  dv.RowFilter = "PartNumber='" + partNumber + "'";
  
                  // Fills data grid in UI.
                  dg.DataContext = dv;
                  PartTypeComboBox.ItemsSource = table_LV.DefaultView;
              }
          }
  public void createDropDowns()
          {
              // Populate part styles from lookup table.
              partTypesList = new ObservableCollection&lt;string&gt;();
              adapter_LV.Fill(table_LV);
              List&lt;string&gt; temp = table_LV.AsEnumerable().Select(x =&gt; x[2].ToString()).ToList();
              foreach (var partType in temp)
              {
                  partTypesList.Add(partType);
              }
              partTypesList.Add(""); // Add a blank option in case user needs to input blank cell.
          }
  </code></pre>
  
  <p>And here is my .xaml:</p>
  
  <pre><code>&lt;DataGrid x:Name="dg" ItemsSource="{Binding}" AutoGenerateColumns="True" AutoGeneratingColumn="m_grid_AutoGeneratingColumn" HorizontalAlignment="Left" Margin="28,-145,-779,0" VerticalAlignment="Top" Height="165" Width="1222" AlternatingRowBackground="LightGray" AlternationCount="2"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridComboBoxColumn x:Name="PartTypeComboBox" 
                                          Header="PartTypeTest" 
                                          DisplayMemberPath="Key" 
                                          SelectedValuePath="Id" 
                                          SelectedValueBinding="{Binding PartType}"/&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>I can get it to create a new ComboBox column with the correct list of information, but I cannot get that combobox to display (or bind?) onto my PartType Column populated from my table_PT data table. Direction? Thanks! </p>