First of all, I looked up this related question in here but the solution dataGridView1.Rows.Add()
doesn\'t work in my case.
In my Datagridview, I have
The best solution I found:
//create datatable and columns
DataTable dtable = new DataTable();
dtable.Columns.Add(new DataColumn("Column 1"));
dtable.Columns.Add(new DataColumn("Column 2"));
//simple way create object for rowvalues here i have given only 2 add as per your requirement
object[] RowValues = { "", "" };
//assign values into row object
RowValues[0] = "your value 1";
RowValues[1] = "your value 2";
//create new data row
DataRow dRow;
dRow = dtable.Rows.Add(RowValues);
dtable.AcceptChanges();
//now bind datatable to gridview...
gridview.datasource=dtable;
gridview.databind();
Source: http://www.codeproject.com/Questions/615379/Adding-rows-to-datagridview-with-existing-columns