title: How to display row number in gridview
body: <p>I use code below but it didint work.. It didnt show me column with that field.</p>
  
  <pre><code>&lt;asp:TemplateField&gt;
    &lt;ItemTemplate&gt;
      &lt;%# Container.DataItemIndex + 1 %&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>I add my other columns in code behind and meaby it's the problem?</p>
  
  <pre><code> OleDbDataAdapter sqlArchiveData = new OleDbDataAdapter(sql_archive);
  
       DataTable dt = new DataTable();
       connProdcc1.Open();
       sqlArchiveData.Fill(dt);
  
  foreach (DataColumn column in dt.Columns)
           {
               BoundField field = new BoundField();
               field.DataField = column.ColumnName;
               field.HeaderText = column.ColumnName.Replace("_"," ");
               field.SortExpression = column.ColumnName;
               AggregateGridView.Columns.Add(field);
           }
  AggregateGridView.DataSource = dt;
           AggregateGridView.DataBind();
  </code></pre>
  
  <p>Does anone have any idea how to do this in other way?</p>
  
  <p>I try to this like below but it's counts my row number after all data I <code>Fill()</code> into a <code>DataTable</code> and then add to each row a number</p>
  
  <pre><code>     DataColumn columnIndexRow = new DataColumn();
       columnIndexRow.DataType = System.Type.GetType("System.Int32");
       columnIndexRow.ColumnName = "id";
       dt.Columns.Add(columnIndexRow);
  
       for (int i = 0; i &lt; dt.Rows.Count; i++)
       {
           // your index is in i
           var row = dt.NewRow();
           row["id"] = i;
           dt.Rows.Add(row);
       }
  </code></pre>