title: How to commit these data row changes back to the DB
body: <p>I have not really worked with datasets before. I use a lot of LINQ / Entity Framework.</p>
  
  <p>Here is the code I have written (it is one part of a switch):</p>
  
  <pre><code>  if (!DataHelper.DataSourceIsEmpty(dsUp))
                  {
                      //get datarow collection from dataset
                      DataRowCollection drc = dsUp.Tables[0].Rows;
                      //Loop through dataset
                      foreach (DataRow dr in drc)
                      {
                          //get current dataset row sortid
                          int sortID = Convert.ToInt32(dr["SortID"]);
                          { 
                          //if its the row above then minus one
                          if (sortID == nodeAbove)
                          {
                              int newID = Convert.ToInt32(dr["SortID"].ToString());
                              newID--;
                              dr["SortID"] = newID;
  
                              //TODO: save changes back to original ds
  
  
                          }
                          }
  
                      }
                  }
  
                  break;
  </code></pre>
  
  <p>I have been trying things like:</p>
  
  <ul>
  <li>dr.AcceptChanges</li>
  <li>dsUp.AcceptChanges(dr)</li>
  <li>drc.copyto(dsUP)</li>
  <li>dsUp.Merge(drc)</li>
  </ul>
  
  <p>and many other similar attempts that have not worked. When googling for this topic all the results I have found use a table adapter... as im working in a cms I get my data like so:</p>
  
  <pre><code>DataSet dsUp = tree.SelectNodes(CurrentSite, path, cultureCode, true, classnames, where, orderby);
  </code></pre>
  
  <p>Any assistance on getting the changes saved back to the db would be massively appreciated
  Cheers.</p>
  
  <p>Since posting I have also tried this method which unfortunately did not work:</p>
  
  <pre><code>        //dataset to hold results before merge 
          DataSet DSResults = tree.SelectNodes(CMSContext.CurrentSite.SiteName, path, cultureCode, true, classnames);
          DSResults.Clear();
  
  
          if (!DataHelper.DataSourceIsEmpty(dsUp))
          {
              //get datarow collection from dataset
              DataRowCollection drc = dsUp.Tables[0].Rows;
              //Loop through dataset
              foreach (DataRow dr in drc)
              {
                  //get current dataset row sortid
                  int sortID = Convert.ToInt32(dr["SortID"]);
                  { 
                  //if its the row above then minus one
                  if (sortID == nodeAbove)
                  {
                      int newID = Convert.ToInt32(dr["SortID"].ToString());
                      newID--;
                      dr["SortID"] = newID;
                      dr.AcceptChanges();
                      DSResults.Tables[0].Rows.Add(dr);
  
  
  
                  }
                  }
  
              }
          }
          //save changes back to original ds
          dsUp.Merge(DSResults);
          dsUp.AcceptChanges();
          break;
  </code></pre>