I hav 2 datagrid one named dgvflag and another named dgvflag1
There r some rows in dgvflag
wen i select one of d row n click on add button dat row should b added to another datagrid named dgvflag1
plzzz help i need code 4 dis urgently
thnxx in advance

Hi,
1st, point is that you have the same columns, ok its not really necessary, but its good when you want to copy a row from on dataGrid to anoter to have at least the same number of columns and that are the same type (even all can be parsed as objects).
So this is the code example:

private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                dataGridView2.Rows.Add();
                int newRow = dataGridView2.Rows.Count - 1;
                foreach (DataGridViewCell cell in row.Cells)
                {
                    dataGridView2[cell.ColumnIndex, newRow].Value = cell.Value;
                }
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.