how to add new rows into a datatable vb.net

Here is an example of adding a new row to a datatable that uses AutoIncrement on the first column:

Define the table structure:

    Dim dt As New DataTable
    dt.Columns.Add("ID")
    dt.Columns.Add("Name")
    dt.Columns(0).AutoIncrement = True

Add a New row:

    Dim R As DataRow = dt.NewRow
    R("Name") = txtName.Text
    dt.Rows.Add(R)
    DataGridView1.DataSource = dt

First You need to define the data table structure as like the following:

Dim dt As New DataTable
dt.Columns.Add("ID", Type.GetType("System.String"))
dt.Columns.Add("Name",Type.GetType("System.String"))

And Then add row like:

Dim dr As DataRow = dt.NewRow
dr("ID") = System.GUID.NewGUID()
dr("Name") = txtName.Text
dt.Rows.Add(dr)
DataGridView1.DataSource = dt
DataGridView1.DataBind()