How to check duplicates for a column using GridDataBoundGrid using C#2010?
Hi Venkata,
Sorry for the delay.
Kindly refer the below provided code snippet and sample for validating the cell duplicates. We have prepared the code snippet similar to the one provided by you. In this code we have checked the values of a specific column with the current cell. Please let us know whether the given solution achieves your requirement.
void gridDataBoundGrid1_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e)
{
GridCurrentCell cc=this.gridDataBoundGrid1.CurrentCell;
if (e.ColIndex == 1)
{
if (!string.IsNullOrEmpty(this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].FormattedText))
{
for (int i = 0; i < gridDataBoundGrid1.Model.RowCount;i++ )
{
if(e.RowIndex!=i)
{
if (this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellValue.ToString() == gridDataBoundGrid1[i, e.ColIndex].CellValue.ToString())
{
MessageBox.Show(this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellValue.ToString() + " is already entered");
this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellValue = string.Empty;
e.Cancel = true;
return;
}
}
}
}
}
}
Please let us know if you have any other concerns.
Thanks & Regards,
AL.Solai.
Attachment: WindowsFormsApplication8_ca49712b.zip
- 1 Reply
- 2 Participants
-
VE Venkata
- Apr 29, 2014 06:08 AM UTC
- May 10, 2014 09:35 AM UTC