Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello! I m making a program to transfer employee's into other branch, therefore I get two datagridview, first for data binding and all employee's list from database, I make my firsdatagridview last coloumns for checkboxcolumns.
I want to that When I m clicking on button transfer then checked rows will be transfer into another or second datagridview, But I m unable to developed this, yes I search more n more time code for this process, but failed. can anyone help me about this problems..

Thanks In Advance
Posted 8-Feb-13 4:10am
Comments
CHill60 at 8-Feb-13 9:33am
   
If you type datagrid copy rows into the search box at the top right of this window you will get several answers on how to do this. If you type "vb net datagridview copy rows to another datagridview" into google you will get 200+ results

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

using System.Collections.Generic;
using System.Data;
using System.Linq; 
 
//DataTable dt_source;
//DataTable dt_destination;

// Selects the rows
var selectedRows = from DataRow r in dt_source.Rows
                   where r["mustTransfer"].Equals(true)
                   select r;
 
// Copy the rows
dt_destination = selectedRows.CopyToDataTable();
 
// Remove old rows
foreach(DataRow row in selectedRows)
    dt_source.Rows.Remove(row);
 
// Then you databind the destination datagridview to the destination datatable (dt_destination).
  Permalink  
Comments
Remoddn at 13-Feb-13 3:32am
   
Thanks Victor! Today I found solution myself and posted with new question and answer
Victor Rene at 14-Feb-13 4:53am
   
I'm happy to know that was helpful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 638
1 Sergey Alexandrovich Kryukov 445
2 ProgramFOX 275
3 CHill60 225
4 Maciej Los 215
0 OriginalGriff 550
1 Sergey Alexandrovich Kryukov 470
2 Maciej Los 310
3 ProgramFOX 275
4 Peter Leow 250


Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100