title: Why is the DataItem null for a GridView row "null" when trying to save changes?
body: <p>So I've got this GridView on my web page. It is databound, so during the RowDataBound event this code works perfectly well:</p>
  
  <pre><code>    protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              TimecardApproval shift = (TimecardApproval)e.Row.DataItem;
          }
      }
  </code></pre>
  
  <p>The "shift" variable has all the data I need, works great. But then there's this code for saving the data:</p>
  
  <pre><code>    protected void btnSubmitApprovals_Click(object sender, ImageClickEventArgs e)
      {
          foreach (GridViewRow item in gvTimeCards.Rows)
          {
              TimecardApproval shift = (TimecardApproval)item.DataItem;
              // code to update the row
          }
      }
  </code></pre>
  
  <p>The DataItem is null! Why? Since the field is there, it seems strange that it's null. Should I be looping over something else?</p>