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

Default string for empty DateTime entry in Data Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

10653 Feb 9,2004 09:09 AM Feb 9,2004 03:26 PM Windows Forms 1
loading
Tags: GridControl
Bidin Dinesababu
Asked On February 9, 2004 09:09 AM

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 03:26 PM

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; } }

CONFIRMATION

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.

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.

;