title: Programmatically Create Checkbox Column inside a Gridview in ASP.NET
body: <p>I often use this code to create template fields for buttons, checkboxes, labels etc. inside a gridview:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Data_1" ShowHeader="False" Visible="True"&gt;
   &lt;ItemTemplate&gt;
    &lt;asp:Button ID="Button1" runat="server" 
    CommandArgument='&lt;%# DataBinder.Eval(Container, "RowIndex") %&gt;' 
    CommandName="Button1_Command" CssClass="round_button" 
    Height="20px" Width="20px" /&gt;
    &lt;/ItemTemplate&gt;
    &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>But this time, the number of columns with checkbox are uncertain. (I need to pull a certain data in the database to determine how many checkbox columns I would need). How do I programmatically create a checkbox column upon page load?</p>
  
  <p>Thanks :)</p>