I have an Ultrawebgrid (can't migrate to WebDataGrid for this yet) with a date column. The Date field is initialized in the InitializeLayout method as such
With e.Layout.Bands(0).Columns.FromKey("DUE_DATE") .Header.Caption = "Due Date" .DataType = "System.DateTime" .Format = "MM/dd/yyyy" .Header.Style.HorizontalAlign = HorizontalAlign.Center .CellStyle.HorizontalAlign = HorizontalAlign.Center End With
When the date is empty(they are not null, empty dates are returned as " ") the date shows as 01/01/0001. I want the date to be empty in this case instead of the pseudo-date. Is there a way to do this in the initialize method or do i have to iterate the grid after it is databound and change it?
Hello dbishop9,My suggestion to achieve this is to handle InitializeRow event and toe.Row.Cells.FromKey("Date").Value = If (e.Row.Cells..FromKey("Date") == "01/01/0001, " ", e.Row.Cells..FromKey("Date"))Which will replace the vallues of all "01/01/0001" dates with " ".Please let me know if this suggestion works for you.
It does and doesn't. The method you suggested "works", but the blank value is still forced to the date because of the formatting in InitializeLayout. So, it only works if I turn off the formatting, but when there is an actual date it is obviously not displayed in the right format.
I played around with it some to see if it would display a non-date value. So I set it to ' ' instead of just " " and the date is gone, thanks to Infragistics rendering dynamic HTML inside their controls. So you suggestion worked great, I just had to play with it a bit. Thanks much for the great answer and timely response, you guys are the best.
Hello Daryl,Please let me know if i understand you correctly. Is the issue resolved? If you have more questions about it do not hesitate to ask me.