Last Updated: 23 Jul 2015 13:47 by ADMIN
Created on: 21 Jul 2015 06:16
Category: GridView
Type: Bug Report
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. 


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
Posted on: 23 Jul 2015 13:47
The issue is duplicated with another feedback item. Here is the link: