Hi Anna,
In general, the PrimaryKey Column does not accept any duplicate and null values..it throws the exception if you change the cell value to the already present cell value.
Will that be ok, for you to programmatically check for repeated entries to avoid the exception in the output window? If so then the validation can be performed in the CurrentCellValidating Event Handler. Please take a look at the sample for more details.
string oldValue, newValue,cValue;
private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if(cc.Renderer.StyleInfo.CellValueType == typeof(DateTime))
{
oldValue = Convert.ToString(this.gridDataBoundGrid1[cc.RowIndex,cc.ColIndex].CellValue);
newValue = cc.Renderer.ControlText + " 12:00:00 AM";
for(int i =1; i < this.gridDataBoundGrid1.Model.RowCount; i++)
{
cValue = this.gridDataBoundGrid1[i,cc.ColIndex].CellValue.ToString() ;
if(newValue == cValue)
if( oldValue == string.Empty)
e.Cancel = true;
else
cc.Renderer.ControlText = oldValue;
break;
}
}
}
Let us know if you need any assistance,
Regards,
Madhan.
Forum_20Jan_39774_validating.zip