title: Datagrid in WPF C#. How to add custom values to each cells in a row
body: <p>I have three textboxes. I need to add each value to the corresponding fields. Datagrid have headers "#, ProductName, ProductCode, Tax, Total"</p>
  
  <p>WPF</p>
  
  <pre><code>                &lt;DataGrid ItemsSource="{Binding dt}" x:Name="dgrdBilling" MinColumnWidth="100" Grid.Row="1" CanUserReorderColumns="False" AutoGenerateColumns="False" SelectionMode="Single" SelectionUnit="Cell" Margin="1,0,-1,0"&gt;
                      &lt;DataGrid.Columns&gt;
                          &lt;DataGridTextColumn Header="#" Width="25" CanUserResize="False" MinWidth="25"/&gt;
                          &lt;DataGridTextColumn Header="Name"/&gt;
                          &lt;!--&lt;DataGridTextColumn Header="Name" Binding="{Binding Path=ProductName}"/&gt;--&gt;
                          &lt;DataGridTextColumn Header="Code"/&gt;
                          &lt;DataGridTextColumn Header="Quantity"/&gt;
                          &lt;DataGridTextColumn Header="Price"/&gt;
                          &lt;DataGridTextColumn Header="Tax1"/&gt;
                          &lt;DataGridTextColumn Header="Tax2"/&gt;
                          &lt;DataGridTextColumn Header="Tax3"/&gt;
                          &lt;DataGridTextColumn Header="Total"/&gt;
                      &lt;/DataGrid.Columns&gt;
                  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Click Event of button to add data to datagrid</p>
  
  <pre><code>    private void btnAddProduct_Click(object sender, RoutedEventArgs e)
      {
          SqlCeCommand com = new SqlCeCommand("SELECT * FROM Products_Master WHERE ProductName =('" + txtAutoProductName.Text + "') OR ProductCode = ('" + txtProductCode.Text + "')", con);
          try
          {
              System.Windows.Controls.DataGrid dg = new System.Windows.Controls.DataGrid();
              SqlCeDataAdapter da = new SqlCeDataAdapter();
              BindingSource bSource = new BindingSource();
              DataTable dt = new DataTable();
              DataRow newRow = dt.NewRow();
              da.SelectCommand = com;
              da.Fill(dt);
              bSource.DataSource = dt;
              dg.Items.Add(txtAutoProductName.Text);
              dg.Items.Add(txtAutoProductCode.Text);
              dg.Items.Add(txtQuantity.Text);
              //dgrdBilling.ItemsSource = dt.DefaultView;
              //dgrdBilling.Items.Add(dg);
              da.Update(dt);
          }
          catch (Exception ex)
          {
              System.Windows.Forms.MessageBox.Show(ex.Message, System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
      }
  </code></pre>