var 多码 = row.Cells["MoreCode"].Value; if (多码 == null || 多码.ToString() != "Y") { row.Cells["MoreCode"].Value = "Y"; } else { row.Cells["MoreCode"].Value = null; }