DBNull.Value

Hello, I use DateTimePickAdv control bound to a table field with datatime type. When the field date is null, it got "object can''t cast from DBNull to other types". any settings I need to set up? Thanks, The code I used: DateTimePickerAdv pDateTimePicker=new DateTimePickerAdv(); pDateTimePicker.Name=string.Format("dt{0}",ColumnName); pDateTimePicker.Tag=ColumnName; pDateTimePicker.EnableNullDate=true; // bound to table field ptmpDateTimePicker.DataBindings.Add("Value",mGridDataSet.Tables[mFormParam.TableName],ColumnName);

1 Reply

AD Administrator Syncfusion Team January 5, 2006 05:03 AM UTC

Hi LanMo, For a DateTimePickerAdv, you need to bind to the BindableValue property. Please see the below given code snippet : ptmpDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("BindableValue", mGridDataSet.Tables[mFormParam.TableName],ColumnName); Also please take a look at the following KB Article. How can you setup databinding to your DateTimePickerAdv ? Best Regards, Anu.

Loader.
Up arrow icon