title: Swapping two button controls
body: <p>Having a bit trouble trying to figure out a way to swap 2 buttons. Let just dive in and show you the code:</p>
  
  <pre><code>            int mCatID;
              int mTempPos;                
  
              mCatID = mCatButList[mValidCatNumber - 1].mCatID - 1;               
  
              if (mTempOldPos.ToString() != txtCatPos.Text) // Attempt to change position
              {
                  foreach (DataRow row in mIMenu.mCategoryList.Rows) // Check if space is taken
                  {
                      if (row[2].ToString() == txtCatPos.Text) // Space is taken
                      {
                           mCatOldIDX = mTempOldID - 2;
                          mTempDesc = mIMenu.mCategoryList.Rows[mCatOldIDX][1].ToString();
  
                          mIMenu.mCategoryList.Rows[mCatOldIDX][1] = row[1].ToString(); // desc
                          mIMenu.mCategoryList.Rows[mCatOldIDX][2] = (int)row[2];        // pos                     
  
                          row[1] = mTempDesc;
                          row[2] = mTempOldPos; //RP change new location to old   
  
                          mCatOldIDX = 0;
  
                          mIMenu.mCategoryList.AcceptChanges();
  
                          break;
                      }
                  }
                 // mIMenu.mCategoryList.DefaultView.Sort = "POS asc";
  
                  CreateCatButList();
                  DisplayMenuCategories(); 
  </code></pre>
  
  <p>[EDIT] I have modified the code and now it seems that it does swap the position of the button controls once. But if I swap two of the controls and then swap one of the swapped buttons with another button it seems to mess up all the position values on all of the other buttons!? This is really starting to bug me.. why does it work for the first time and then not for others? Ive tried accept changes and still no effect.. Its all to do with the value in the Datatable <code>mIMenu.mCategoryList</code> where column <code>[1]</code> is Description and <code>[2]</code> is the Position. What is frustrating is why would it work once changing the value and then as soon as the state changes to modified decides to revert back to older position values?</p>