title: Updating DataTable bound to ASP.Net DataGrid
body: <p>I am having a problem updating a datatable that is bound to a datagrid. Tried a bunch of approaches but the problem is t<strong>he underlying datatable reverts back to its initial state</strong> everytime u click a command.</p>
  
  <p>Here's the example code:</p>
  
  <p><strong>On Label Click:</strong></p>
  
  <pre><code>protected void OnUserDataGridCommand(object source, DataGridCommandEventArgs e)
          {
              DataTable dt = DataGridUsers.DataSource as DataTable;
  
              if (e.CommandName == "Lock Out")
              {
                  // Approach 1
                  e.Item.Cells[0].Text = "Lock";
                  DataGridUsers.DataSource = dt;
                  DataGridUsers.DataBind();
  
                  // Approach 2              
                  dt.Rows[e.Item.ItemIndex]["FirstName"] = "LOCK";
                  dt.Rows[e.Item.ItemIndex].AcceptChanges();
  
                  DataGridUsers.DataSource = dt;
                  DataGridUsers.DataBind();                
              }
          }
  </code></pre>
  
  <p>So this will update the row's first name to say Lock but when you click on another row the previously Locked will revert to the first name. When I breakpoint regardless of a row displaying lock, the datatable always is the initial data (no "LOCK" data).</p>