Don't create a new DataTable for the second grid everytime you select a row on the first grid.
in the form load, create your DataTable and columns for the second grid, something like this:
private DataTable SecondDataTable = new DataTable();
private void MainForm_Load(System.Object sender, System.EventArgs e)
{
SecondDataTable.Columns.Add("Student ID");
SecondDataTable.Columns.Add("Roll Number");
SecondDataTable.Columns.Add("Student Names");
}
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
foreach (DataGridViewRow r in dataGridView1.SelectedRows)
{
int stdid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
string stdname = dataGridView1.CurrentRow.Cells[1].Value.ToString();
dataGridView1.Rows.Remove(r);
DataRow dr;
dr = SecondDataTable.NewRow();
int i = 1;
dr[0] = stdid;
dr[1] = i;
dr[2] = stdname;
SecondDataTable.Rows.Add(dr);
i++;
this.dataGridView2.DataSource = SecondDataTable;
}
}