c# datagridview comparison....
how to compare datagridview's and display the difference in another grid?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Santhosh Kumar JayaramanPosted Aug 20, 2012, 7:20 AM
public bool compareTbls(Datatable tbl1, Datatable tbl2)
{
if(tbl1.Rows.Count != tbl2.Rows.Count || tbl1.Columns.Count != tbl2.Columns.Count)
return false;
for(int i = 0; i < tbl1.Rows.Count; i++)
{
for(int c = 0; c < tbl.Columns.Count; c++)
{
if(tbl1.Rows[i][c] != tbl2.Rows.Columns[i][c])
return false;
}
}
return true;
}
Also if you want to compare using linq,
then check below linq.
http://www.codeproject.com/Tips/344792/Compare-two-datatable-using-LINQ-Query
hj jhPosted Aug 20, 2012, 7:23 AM
Gopal MahadakPosted Aug 20, 2012, 6:23 AM
send code
Sukesh MarlaPosted Aug 20, 2012, 6:15 AM
Comparing datatable will be a good idea instead of grid
Check this as correct answer if helped
Gopal MahadakPosted Aug 20, 2012, 6:09 AM
name password
abc 123
xyz 321
asd 147
jkl 963
another datagridview contains:
name password
abc 123
xyz 321
So compare both... & display its difference in another datagridview.. please help..
trying from one day... send code...
hj jhPosted Aug 20, 2012, 6:03 AM