Add column(s) in front of the GridView column in C#
<p>In my project, it is a table which shows some details of someone and a button to do somethings.</p>

<p>The table looks like:</p>

<pre><code>-----------------------------
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
</code></pre>

<p>However, i cannot add those column in front of the Btn column which the Btn column is defined with asp GridView control and others columns are defined with dataTable in C#.</p>

<p>Therefore, How do i add those column in C#?</p>

<p>Code:
GridView:</p>

<pre><code>                  &lt;asp:GridView ID="GridView1" runat="server"&gt;
                        &lt;Columns&gt;
                            &lt;asp:BoundField DataField="Name" HeaderText="Name" /&gt; // if i remove these =&gt; errors
                            &lt;asp:BoundField DataField="detail" HeaderText="detail" /&gt;
                            &lt;asp:BoundField DataField="other" HeaderText="other" /&gt;

                            &lt;asp:TemplateField&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:ImageButton ID="imgbtn" runat="server" ImageUrl="../Image/btn.png" /&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;
                       &lt;/Columns&gt;
                   &lt;/asp:GridView&gt;
</code></pre>

<p>Code: dataTable</p>

<pre><code>        var DT = new DataTable();
        DT .Columns.Add("Name", typeof(string));// if i remove these =&gt; errors
        DT .Columns.Add("Detail", typeof(string));
        DT .Columns.Add("other", typeof(string));

      .....foreach loop
                 DataRow dr = DT .NewRow();
                 dr["Name"] = item["Name"];
                 dr["Detail"] = item["Detail"];
                 dr["other"] = item["other"];
                 waitDT.Rows.Add(dr);
      .....end of foreach loop

        GridView1.DataSource = DT;
        GridView1.DataBind();
</code></pre>

<p>So, the result i getting is: </p>

<pre><code>-----------------------------------------------------
name | detail | other | Btn | name | detail | other |
name | detail | other | Btn | name | detail | other |
name | detail | other | Btn | name | detail | other |
name | detail | other | Btn | name | detail | other |
name | detail | other | Btn | name | detail | other |
name | detail | other | Btn | name | detail | other |
</code></pre>

<p><strong>Main Question:</strong></p>

<p>I want to define the btn column in asp control and others in C#.</p>

<p>it should look like:
                      
                            </p>

<pre><code>                            &lt;asp:TemplateField&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:ImageButton ID="imgbtn" runat="server" ImageUrl="../Image/btn.png" /&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;
                       &lt;/Columns&gt;
                   &lt;/asp:GridView&gt;
</code></pre>

<p>then the C#:</p>

<pre><code>    var DT = new DataTable();
    DT .Columns.Add("Name", typeof(string));//it should place in front of the btn column
    DT .Columns.Add("Detail", typeof(string));
    DT .Columns.Add("other", typeof(string));

  .....foreach loop
             DataRow dr = DT .NewRow();
             dr["Name"] = item["Name"];
             dr["Detail"] = item["Detail"];
             dr["other"] = item["other"];
             waitDT.Rows.Add(dr);
  .....end of foreach loop

    GridView1.DataSource = DT;
    GridView1.DataBind();
</code></pre>

<p>finally the result:</p>

<pre><code>-----------------------------
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
name | detail | other | Btn |
</code></pre>