How to delete rows from DataGridView without delete rows from DataTable?
Solution
Copy original DataTable
Example:
DataTable dt1 = dt.Copy();
dataGridView1.DataSource = dt1;
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
dt.Columns["ID"].AutoIncrement = true;
dt.Columns["ID"].AutoIncrementSeed = 1;
dt.Columns["ID"].ReadOnly = true;
dt.Columns.Add("Name", typeof(string));
dynamic dr = dt.NewRow();
dr("Name") = "John";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr("Name") = "Dan";
dt.Rows.Add(dr);
DataGridView1.DataSource = dt;