This is a migrated thread and some comments may be shown as answers.

FileDescriptor.Value : Handling null value

2 Answers 14 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 29 Jun 2011, 05:41 PM
Good morning,

I am using your CustomFilterDescript sample from your RadControl demos and I have an error when my descriptor.value is null.

private IFilterDescriptor CreateFilterForColumn(GridViewDataColumn column)
        {
            FilterOperator filterOperator = GetFilterOperatorForType(column.DataType);
            FilterDescriptor descriptor = new FilterDescriptor(column.UniqueName, filterOperator, this.filterValue);
            descriptor.MemberType = column.DataType;
 
            return descriptor;
        }

For example I have : ColumnName is EqualTo Null.
This produce an error on this line :

convertedValue = Convert.ChangeType(this.FilterValue, descriptor.MemberType, CultureInfo.CurrentCulture);


How can I handle this?

Regards,
Steven

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 30 Jun 2011, 06:14 AM
Hello Steven,

Add a check for when a null value arrives and replace it with the special singleton value FilterDescriptor.UnsetValue. When the Value if a FilterDescriptor is FilterDescriptor.UnsetValue it is as though it does not exist at all.

Alternatively, you can modify the code to do nothing, i.e. to not produce any descriptor when the incoming value is null.

I hope this helps.

Greetings,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Steven
Top achievements
Rank 1
answered on 30 Jun 2011, 08:45 AM
Thank you :)
Tags
GridView
Asked by
Steven
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Steven
Top achievements
Rank 1
Share this question
or