Question: I have a `DataGridView` binded to a `DataTable` (`DataTable` binded to database). I need to add a `DataRow` to the `DataTable`. I'm trying to use the following code:

```
dataGridViewPersons.BindingContext[table].EndCurrentEdit();
DataRow row = table.NewRow();

for (int i = 0; i < 28; i++)
{
    row[i] = i.ToString();
}

```

But it doesn't work, `DataGridView` has never been added a new row. Please, tell me, how can I fix my code? 

Thank you in advance.

Answer: 
I found [dotnetperls examples on `DataRow`](https://www.dotnetperls.com/datarow) very helpful. Code snippet for new `DataTable` from there:

```
static DataTable GetTable()
{
    // Here we create a DataTable with four columns.
    DataTable table = new DataTable();
    table.Columns.Add("Weight", typeof(int));
    table.Columns.Add("Name", typeof(string));
    table.Columns.Add("Breed", typeof(string));
    table.Columns.Add("Date", typeof(DateTime));

    // Here we add five DataRows.
    table.Rows.Add(57, "Koko", "Shar Pei", DateTime.Now);
    table.Rows.Add(130, "Fido", "Bullmastiff", DateTime.Now);
    table.Rows.Add(92, "Alex", "Anatolian Shepherd Dog", DateTime.Now);
    table.Rows.Add(25, "Charles", "Cavalier King Charles Spaniel", DateTime.Now);
    table.Rows.Add(7, "Candy", "Yorkshire Terrier", DateTime.Now);

    return table;
}

```
try `table.Rows.add(row);` after your `for` statement.