Declined
Last Updated: 23 Jul 2015 13:47 by ADMIN
Todor
Created on: 21 Jul 2015 06:16
Category: GridView
Type: Bug Report
1
FIX. RadGridView - sorting a date time column containing nulls causes an exception.
Steps to reproduce:

1. Add a GridViewDateTimeColumn to a grid.

2. Add rows where one or more rows should contain null as the columns value.

3. Sort the grid by the date time column. 



WORKAROUND:

Create a custom RadGridDateTimeConverter and assign it as the column's date type converter:

public class CustomRadGridDateTimeConverter : RadGridDateTimeConverter
{
    public CustomRadGridDateTimeConverter(GridViewDateTimeColumn column)
        : base(column)
    { }

    public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
    {
        if (destinationType == typeof(DateTime) && value == null)
        {
            return DateTime.MinValue;
        }

        return base.ConvertTo(context, culture, value, destinationType);
    }
}



this.radGridView1.Columns["DateTime"].DataTypeConverter = new CustomRadGridDateTimeConverter(this.radGridView1.Columns["DateTime"] as GridViewDateTimeColumn);
1 comment
ADMIN
Ralitsa
Posted on: 23 Jul 2015 13:47
The issue is duplicated with another feedback item. Here is the link: http://feedback.telerik.com/Project/154/Feedback/Details/162527-fix-radgridview-sorting-a-date-time-column-containing-nulls-causes-an-exceptio