if add row to DataTable
DataRow row = datatable1.NewRow();
row["column2"]="column2";
row["column6"]="column6";
datatable1.Rows.Add(row);
How about DataGridView
??
if add row to DataTable
DataRow row = datatable1.NewRow();
row["column2"]="column2";
row["column6"]="column6";
datatable1.Rows.Add(row);
How about DataGridView
??
Like this:
Or you need to set there values individually use the propery
.Rows()
, like this:You can do:
or:
Another way:
From: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rows.aspx
If you´ve already defined a
DataSource
, You can get theDataGridView
´sDataSource
and cast it as aDatatable
.Then add a new
DataRow
and set the Fields Values.Add the new row to the
DataTable
and Accept the changes.In C# it would be something like this..
Lets say you have a datagridview that is not bound to a dataset and you want to programmatically populate new rows...
Here's how you do it.
here is another way to do such
you can also create a new row and then add it to the DataGridView like this: