I have a DataTable
and I created a DataView
from the DataTable
. I grab a record from the DataTable
(Let's say record 5). Then I sort the DataView
and I am trying to find the new index of the record I grabbed prior to sorting the DataView
.
So to find the location of the new record I will loop through each record and each item in the record until I find a record that has all matching items in the record.
My loop looks like this:
int currentRecord = 2;
DataRow tr = view.Table.Rows[currentRecord];
view.Sort = "Name ASC";
foreach (DataRowView drv in view)
{
foreach(object itemA in tr.ItemArray)
{
foreach (object itemB in drv.Row.ItemArray)
{
Console.WriteLine("{0} == {1}", itemA, itemB);
if(itemA == itemB)
{
Console.WriteLine("Match!");
}
}
}
}
So as you can see here in the pictures it's returning true for object{string}
but false for object{int}
even when the values are the same.
What's going on here?