比较2个网格视图并从gv2更新GVL

本文关键字:gv2 更新 GVL 2个 网格 视图 比较 | 更新日期: 2023-09-27 18:18:14

我想比较oldgridview与newgridview和更新newgridview从oldgridview使用asp.net和c#

有谁能支持我吗

谢谢

比较2个网格视图并从gv2更新GVL

protected void Button2_Click(object sender, EventArgs e)
    {
        DataTable src1 = gv1.DataSource as DataTable;
        DataTable src2 = gv2.DataSource as DataTable;
        int index1 = 0;
    foreach (DataRow row1 in src1.Rows)
    {
        foreach (DataRow row2 in src2.Rows)
        {
            int index2 = 0;
            bool duplicateRow  = true;
            for (int cellIndex = 0; cellIndex < row1.ItemArray.Count(); cellIndex++)
            {
                if (!row1.ItemArray[cellIndex].Equals (row2.ItemArray[cellIndex].ToString()))
                {
                    duplicateRow  = true;
                    break;
                }
            }
            if (duplicateRow)
            {
                gv1.Rows[index1].DefaultCellStyle.ForeColor  = Color.Red;
            }
            index2++;
        }
        index1++;
    }
}