8
Answers

Transfer Data From One Datagridview To Another

mahesh waghela

mahesh waghela

13y
12.4k
1
I have a two datagridview as 

datagridview1
datagridview2

datagridview1 has a checkbox columns which check the rowindex and transfer the same row to another datagridview2

datagridview1 is a databound control and having columns as below:

checkbox Column,Name and Amount

where as datagridview2 also having same column accept checkbox column.

I wants to transfer data of datagridview1.selected rows to another datagridview2 by click on checkbox column.

How to do?.


Answers (8)
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 14y

Use Linq to datatable, refer sample.
DataTable dtMain = new DataTable();
DataTable dt1 = new DataTable();
//bind datatable
var rows1_10 = from item in dt1.AsEnumerable()
     select item;
var top1_10 = rows1_10.Take(10);
//do a for-loop and insert into dtMain
DataTable dt2 = new DataTable();
//bind datatable
var rows2_10 = from item in dt2.AsEnumerable()
     select item;
var top2_10 = rows2_10.Take(10);
//do a for-loop and insert into dtMain
0
Rajesh Kumar

Rajesh Kumar

NA 66 0 14y

Hi Purna,
Try to create  two temp datasets with a datatable containing 10 rows. and bind these two dataset to gridviews seperately.
Thanks
Rajesh