title: Dynamically add/delete rows from GridView ASPX to CS (source);
body: <p>I want to create GridView like this in C# Class library:</p>
  
  <p><a href="https://i.stack.imgur.com/urWgU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/urWgU.jpg" alt="enter image description here"></a></p>
  
  <p><strong>This is ASPXsource for UI:</strong></p>
  
  <pre><code>&lt;asp:gridview ID="Gridview1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowcreated="Gridview1_RowCreated"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="RowNumber" HeaderText="Row Number" /&gt;
          &lt;asp:TemplateField HeaderText="Header 1"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Header 2"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Header 3"&gt;
              &lt;ItemTemplate&gt;
                   &lt;asp:TextBox ID="TextBox3" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
              &lt;FooterStyle HorizontalAlign="Right" /&gt;
              &lt;FooterTemplate&gt;
               &lt;asp:Button ID="ButtonAdd" runat="server" Text="Add New Row"
                      onclick="ButtonAdd_Click" /&gt;
              &lt;/FooterTemplate&gt;
          &lt;/asp:TemplateField&gt;
               &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click"&gt;Remove&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:gridview&gt;
  </code></pre>
  
  <p><strong>I want to format ASPX to CS (source), like this format :</strong></p>
  
  <pre><code>{
      myGrid = new SPGridView();
      myGrid.ShowFooter = true;
      myGrid.AutoGenerateColumns = false;
      myGrid.ID = "Gridview1";
  
      SPBoundField dest = new SPBoundField();
      dest.DataField = "Number";
      dest.HeaderText = "Number";
  
      TemplateField headerOne = new TemplateField();
  
      base.CreateChildControls();
  }
  </code></pre>
  
  <p>I have no idea how to do this, please help.</p>