private bool CompareSortedRowsByParentAndChildId(DataView dv, DataRow[] drTable)
{
if (dv.Count != drTable.Length) throw new Exception("DataRows[] length are different");
//comparing the rows by using columns ParentId and ChildId
for (int i = 0; i < dv.Count; i++)
{
if (dv[i].Row["ParentId"].ToString() != drTable[i]["ParentId"].ToString()
&&
dv[i].Row["ChildId"].ToString() != drTable[i]["ChildId"].ToString())
return false;
}
return true;
}