title: How to put EDIT and DELETE buttons at the end columns for data grid view retrieved directly from database?
body: <p>I've this datagrid view in which filled directly from binding with database.</p>
  
  <p>I get the data from database in controller in <code>OleDbAdapter</code> type and retrieve it in main window place it in the data grid view. After that, I add the buttons for <code>EDIT</code> and <code>DELETE</code> using <code>DataGridTemplateColumn</code> in <code>Main Window.xaml</code>.</p>
  
  <p><strong>PROGRAM_CONTROLLER.CS</strong></p>
  
  <pre><code>public OleDbDataAdapter GetProgramList()
  {
          OleDbDataAdapter da = null;
  
          try
          {
              con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Path + ";Persist Security Info=True";
              if (con.State != ConnectionState.Open)
              {
                  con.Open();
              }
              OleDbCommand cmd = new OleDbCommand();
              cmd.Connection = con;
              cmd.CommandText = "select * from program";
              return new OleDbDataAdapter(cmd);
          }
          catch(Exception ex)
          {
              return da;
          }
          finally
          {
              con.Close();
          }
  }      
  </code></pre>
  
  <p><strong>MAIN WINDOW.CS</strong></p>
  
  <pre><code>Program_Controller _PController = new Program_Controller();
  OleDbDataAdapter da = _PController.GetProgramList();
  DataTable dt = new DataTable();
  da.Fill(dt);
  dataGridProgram.ItemsSource = dt.AsDataView();
  </code></pre>
  
  <p><strong>MAIN WINDOW.XAML</strong></p>
  
  <pre><code>&lt;WrapPanel Margin="20,0,20,20" HorizontalAlignment="Center"&gt;
      &lt;DataGrid AutoGenerateColumns="True" Name="dataGridProgram" SelectionMode="Single" FontSize="15" BorderThickness="1" IsReadOnly="true" Height="300" Width="700"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTemplateColumn&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;Button x:Name="btnEdit" Content="Edit" Height="Auto" Width="75" Margin="10" Click="btnEdit_Click"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
              &lt;DataGridTemplateColumn&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                         &lt;Button x:Name="btnDelete" Content="Delete" Height="Auto" Width="75" Margin="10" Click="btnDelete_Click"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
          &lt;/DataGrid.Columns&gt;
       &lt;/DataGrid&gt;
  &lt;/WrapPanel&gt;
  </code></pre>
  
  <p>Currently the output result shows the <code>EDIT</code> and <code>DELETE</code> buttons are at the first and second column is like this.</p>
  
  <p><a href="https://i.stack.imgur.com/DSCPZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DSCPZ.png" alt="Current table for data grid view"></a></p>
  
  <p>How can I move them to the back end of row and how to put them both in only one column?</p>
  
  <p><strong>EDIT :</strong> I
  I only want the buttons column at the back, other should remained follow the sequence of columns in database</p>