Dear all,
In the ultragrid1, there is a datetime field named as "EXPIRY_DATE". How to make it show as empty when it is null or it is DateTime.MinDateTime. I am trying to assign null value to it, but it throw exception. Is there any other method without amending the datetime field to be string??
private void ultragrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (Convert.ToDateTime(e.Row.Cells["EXPIRY_DATE"].Value) == DateTime.MinValue) e.Row.Cells["EXPIRY_DATE"].Value = null; // it throws exception that cannot convert }
If you are getting an exception when setting the cell value to null, it's most likely because the DataSource you are binding to the grid does not allow nulls for that field.
What kind of data source are you using?
I am just using DataSet returning from the function. What can I do then??
this.ugdRMA.DataSource =StaticUtil.GetDataset_RMAItems(this.RMAList, false);
public static DS_RMAItems GetDataset_RMAItems(StoreServer.VO.Item.ItemReturnedInventoryListVO rmaList, bool hist) { DS_RMAItems crDS = new DS_RMAItems(); DS_RMAItems.DT_RMA_ITEMSRow dr;
........................
Hi,
If you are binding to a DataSet and the field allows DBNull, then clearing out the cell in the grid should work.
Are you sure the exception you are seeing is not a FirstChanceException that the grid is already catching and handling? You might only be seeing the exception because you have your Visual Studio IDE set to break on all exceptions.
I tested this out binding the grid to a DataTable with a DateTime field that allows DBNull and it works just fine for me. I have attached my sample here so you can take a look.