Ghamai Khuram

Ghamai Khuram

  • 1.7k
  • 19
  • 2.2k

copy data from one datagridview to another if strings match

Jul 9 2018 10:38 AM
I am importing data from excel to Datagridview1 and Datagridview2 which has columns of Group number, Member name
I want to copy the Group number from dataGridview2 to Datagridview1 if Member name is matching non case sensitive ignore characters like .,- and ect. something like .contains will be great
below are the codes that i already tried and after error/failed i converted them to comment
foreach (DataGridViewRow kk in datagridcorrect.Rows)
{
foreach (DataGridViewRow cell in Memnum.Rows)
{
//string corct;
//string memn;
//corct = kk.Cells[0].Value.ToString();
// memn = cell.Cells[0].Value.ToString();
// corct = Convert.ToString(kk.Cells[0].Value);
// memn = Convert.ToString(cell.Cells[0].Value);
//bool b;
// b = kk.Cells[0].Value.ToString().Contains(cell.Cells.ToString());
// if(mem.Equals(correct))
//if (object.Equals(kk.Cells[1].Value, cell.Cells[1].Value))
// if(b == true)
{
kk.Cells[0].Value = cell.Cells[0].Value;
}
}
}
I really worked alot on this any help will be highly appreciated!
thanks

Answers (2)