We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GDBG Control: show nulls and reset values.

Hello. I have I already asked you about how to show (null)s for nullable empty fields in GridGroupingControl. I need the same functionality for GridDataBoundGrid, but I cannot done it same way. Please tell me how to implement showing nulls like in standard DataGrid control. Either I need the functionality to reset the value in datasource to DBNull for current cell. Thanks.

3 Replies

AD Administrator Syncfusion Team August 23, 2004 02:52 AM

To display (null), you can use the PrepareViewStyleInfo event.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.Style.CellValue == null || e.Style.CellValue == DBNull.Value)
		e.Style.Text = "(null)";
To set teh current cell to DBNull, you can use code like: GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; cc.EndEdit(); this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellValue = DBNull.Value;

AD Administrator Syncfusion Team August 23, 2004 10:27 PM

And how to check that the data source allows nulls for current cell ?

AD Administrator Syncfusion Team August 24, 2004 01:18 AM

You can try: int field = grid.Binder.ColIndexToField(grid.CurrentCell.ColIndex); if(myDataTable.Columns[field].AllowDBNull) { //accepts DBNull. }

Live Chat Icon For mobile
Up arrow icon