title: how to add new rows into a datatable vb.net
body: <p>I have a form with a textbox and a "add" button. </p>
  
  <ol>
  <li>The user can write a name down on the textbox and click the "add" button. It will save in a datatable with auto ID. </li>
  <li>After that, the textbox is cleared and the user can write another name in the text box and click the button. </li>
  <li>This should add to the existing datatable in memory with existing ID + 1.</li>
  <li>Then show in the gridview. (this is just for display purpose to confirm it works)</li>
  </ol>
  
  <p>I have a datatable like this. </p>
  
  <pre><code>    Button1.click() event
  
      Dim name = txtname.Text
      Dim dt As New DataTable
      dt.Columns.Add("ID", GetType(Integer))
      dt.Columns.Add("Name", GetType(String))
      Dim N As Integer = dt.Columns("ID").AutoIncrement
      dt.Rows.Add(N, name)
      GridView1.DataSource = dt
      GridView1.DataBind()
      txtname.Text = ""
  </code></pre>
  
  <p>At the moment I have sometime like the code above. in the real program, it is not just name and it is not just one datatable so i just mock up some code.</p>
  
  <p>and this code for aspx.</p>
  
  <pre><code>        &lt;asp:TextBox ID="txtname" runat="server"&gt;
          &lt;/asp:TextBox&gt;&lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
          &lt;asp:GridView ID="GridView1" runat="server"&gt;
          &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>can anyone advice me how to do it ? i understand my code is crapped and not correct but i just have to put some code so that you guys not need to work from scratch for me. </p>
  
  <p>Thanks so much. </p>