title: Better way to get values of datagrid cell
body: <p>i have got dategrid which populated from sql query</p>
  
  <pre><code>HPEntities db = new HPEntities();
  var queryTable4 = db.Database.SqlQuery&lt;Lbrctn&gt;("select * from Lbrctn");
  var u = queryTable4.ToList();
  DG_Example.ItemsSource = u;
  </code></pre>
  
  <p>i want to get the values of those row of my dataGrid which has checked. and send to Stored Procedure
  so i try this code:</p>
  
  <pre><code> for (int i = 0; i &lt; DG_Example.Items.Count - 1; i++)
              {
  
                  mChkBox = DG_Example.Columns[0].GetCellContent(DG_Example.Items[i]) as CheckBox;
  
                  if (mChkBox.IsChecked == true)
                  {
  
                      var DaSelect = DG_Example.Columns[1].GetCellContent(DG_Example.Items[i]) as TextBlock;
                      var MNameTBk = DG_Example.Columns[2].GetCellContent(DG_Example.Items[i]) as TextBlock;
                      var ChiCodeTBk = DG_Example.Columns[3].GetCellContent(DG_Example.Items[i]) as TextBlock;
                      var ChiNameTBk = DG_Example.Columns[4].GetCellContent(DG_Example.Items[i]) as TextBlock;
  
                      var IntenCodeTBk = DG_Example.Columns[6].GetCellContent(DG_Example.Items[i]) as TextBlock;
                      var PeDescTBk = DG_Example.Columns[7].GetCellContent(DG_Example.Items[i]) as TextBlock;
  
                      db.sp_Ins_inten // using Stored Procedure
                          (
                          IntenCodeTBk.Text.Trim(),
                          MNameTBk.Text.Trim(),
                          Convert.ToInt32(chiCodeTBk.Text.Trim()),
                          ChiNameTBk.Text.Trim(),
                          PeDescTBk.Text.Trim(),
                          DaSelect.Text.Trim()
  
                          );
  
                      db.SaveChanges();
  
                  }
  
              }
  </code></pre>
  
  <p>is there a better way than <em>GetCellContent</em> to get values of datagrid row I could use?
  thanx in advance</p>