checkbox and null values

Im using GridDataBoundGrid with DataTable as datasource. One of the field of datatable has bool datatype and doesn''t allow null. I connected this field to checkbox in grid. If I press "del" on keybord and move to another row I get exception. Where can I handle this exception without loosing form? For example I can use string data type for field and textbox as style for column and I will receive normal message from grid, without any exception and loosing form. What am I doing wrong? I''m using such code for checkbox: GridBoundColumn col; col=new GridBoundColumn(); col.HeaderText="Import"; col.MappingName="bIsImport"; col.StyleInfo.CellType = "CheckBox"; col.StyleInfo.CellValueType = typeof(bool); col.StyleInfo.CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);

2 Replies

AD Administrator Syncfusion Team September 3, 2004 12:00 PM UTC

We will try to fix this. Until we have a release with it corrected, you can avoid the problem by handling grid.Model.ClearingCells and cancel the clearing if your user is trying to delete the checkbox column. You could also display a message there or you could do some special action like setting the checkbox to false in teh handler (to simulate clearing them).
//subscribe 
this.gridDataBoundGrid1.Model.ClearingCells += new GridClearingCellsEventHandler(Model_ClearingCells);
		
//the handler
private void Model_ClearingCells(object sender, GridClearingCellsEventArgs e)
{
	if(e.RangeList.AnyRangeIntersects(GridRangeInfo.Col(2)))
		e.Handled = true;
}


AD Administrator Syncfusion Team September 3, 2004 12:07 PM UTC

thank you

Loader.
Up arrow icon