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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Default string for empty DateTime entry in Data Grid

Thread ID:





10653 Feb 9,2004 02:09 PM UTC Feb 9,2004 08:26 PM UTC WinForms 1
Tags: GridControl
Bidin Dinesababu
Asked On February 9, 2004 02:09 PM UTC

Hi, I am using Data bound grid. One column is of type DateTime. In certain cases( Time field is Not applicable in certain cases.), I need to display string "N/A" in the cell. Is there any way to do the same. I can not make the column of type string and fill it on my own, as I need the sort facility for this column. Thanks in advance, Bidin

Administrator [Syncfusion]
Replied On February 9, 2004 08:26 PM UTC

If you put a special DateTime value (say DateTime.MinValue) in these cells, then you can use these two events to handle this tasks. this.gridDataBoundGrid1.Model.QueryCellFormattedText += new GridCellTextEventHandler(gridModel_QueryCellFormattedText); this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(gridModel_QueryCellInfo); private void gridModel_QueryCellFormattedText(object sender, GridCellTextEventArgs e) { if(e.Value.Equals(DateTime.MinValue)) { e.Text = "N/A"; e.Handled = true; } } private void gridModel_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if(e.Style.CellType == "MonthCalendar" && e.Style.CellValue.Equals(DateTime.MinValue)) { e.Style.ReadOnly = true; e.Style.Clickable = false; } }


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon