title: gridview edit mode programmatically
body: <p>I have a basic gridview to which I am binding the data from the code behind from a SQL stored procedure.</p>
  
  <pre><code>&lt;asp:GridView ID="gvCheckResults" runat="server" 
          OnRowDataBound="gvCheckResults_RowDataBound" 
          RowStyle-CssClass="gridViewRow" 
          CssClass="gridView"
          AlternatingRowStyle-CssClass="gridViewAlternatingRow" 
          HeaderStyle-CssClass="gridViewHeader"&gt;
      &lt;/asp:GridView&gt; 
  </code></pre>
  
  <p>Databind:</p>
  
  <pre><code>gvCheckResults.DataSource = dataContext.GetResults(Name, Address);
  gvCheckResults.DataBind();
  
  if (!IsPostBack)
  {
      //Add Edit column.
      CommandField cField = new CommandField();
      cField.EditText = "Edit";
      cField.ShowEditButton = true;
      gvCheckResults.Columns.Insert(0, cField);
  }
  </code></pre>
  
  <p>How can I programmatically add Edit button to each result row?
  I know how to do it when the datasource object is setup in the aspx page, but never done it programmatically.</p>