title: Fill Datagridview row by row from a datatable by manually mapping columns
body: <p>I'm a VB.Net coder, but trying to approach C# programming<br>
  In VB.NET I can write like this without any hassle</p>
  
  <pre><code>For i As Integer = 0 To dt.Rows.Count - 1 'dt is datatable
      dgv.Rows.Add()
      dgv.Rows(i).Cells("Sno").Value = i + 1
      dgv.Rows(i).Cells("itemcode").Value = dt.Rows(i)("itemcode").ToString.Trim
      dgv.Rows(i).Cells("itemname").Value = dt.Rows(i)("itemname")
  Next
  </code></pre>
  
  <p>But when I code in C#</p>
  
  <pre><code>for (int i = 0; i &lt;= dt.Rows.Count-1; i++) //dt is datatable
  {
      DG.Rows.Add();
      DG.Rows(i).Cells("Sr").Value = i + 1;
      DG.Rows(i).Cells("Itemcode").Value = dt.rows(i)("itemcode");
  }
  </code></pre>
  
  <p><code>DG.Rows(i).Cells("Sr").Value = i + 1;</code> gives error </p>
  
  <blockquote>
    <p>Non-invocable member 'DataGridView.Rows' cannot be used like a
    method.</p>
  </blockquote>
  
  <p>What am i doing wrong?</p>