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

NullReferenceException on GridViewDataColumn with nullable DateTime

3 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Dec 2011, 04:23 PM
Good afternoon.

I have some XAML that worked fine with release 2011.1.502.35, but I want to upgrade to the latest version (2011.3.11.16.0).

Unfortunately, I have a number of GridViews with GridViewDataColumn fields bound to nullable DateTime fields like this -

 

  <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Precedence}" Header="Precedence" IsReadOnly="True" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding OffenceFromDate}" Header="From Date"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding OffenceToDate}" Header="To Date"/>
            <telerik:GridViewComboBoxColumn ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.Queues}"
                                    SelectedValueMemberPath="OID"
                                    DataMemberBinding="{Binding AllocationQueue}"
                                    DisplayMemberPath="Name"
                                    Header="Assign To Queue"
                                    IsComboBoxEditable="True" />
  </telerik:RadGridView.Columns>           
</telerik:RadGridView>

When I load up a grid containing a row that contains a null value in either OffenceFromDate or OffenceToDate, I'm now getting the following exception -

Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(System.Windows.Size)

System.NullReferenceException occurred
  Message=Object reference not set to an instance of an object.
  Source=Telerik.Windows.Data
  StackTrace:
       at Telerik.Windows.Data.Expressions.UnboxT`1.NullableField[TElem](Object value) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Expressions\MemberAccess\Unbox.cs:line 39
  InnerException:

Is there any way around this? As I mentioned earlier, the older release was fine with these records.

Thanks for your time.

Paul

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 05 Dec 2011, 09:43 AM
Hello Paul,

 I was not able to get such an exception when the bound property is of type DateTime? and it has a "null" value.

Please check the attached project and let me know how it is different from yours.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Paul
Top achievements
Rank 1
answered on 05 Dec 2011, 09:54 AM
Good morning Didie

I've done a little more work on this to try and reduce the problem to something more manageable by removing some fields from the page, and I'm starting to think that the problem is down to some DateFormDateField controls on the page.

The page is split between a DataGrid and a linked templated DataForm, and I'm wondering if the problem is happening because I've split the form to use a third of it for the grid and the remaining two thirds for the form, so when the null date is being rendered it's trying to work out the size of the allocation it needs.

I'll carry on loking at it and I'll update the post either today to tomorrow.

Thanks

Paul
0
Paul
Top achievements
Rank 1
answered on 06 Dec 2011, 09:54 AM
Hello again Didie.

I'm going to close this now. I think it was a DataGrid issue and I only hit it when I was debugging with all exceptions turned on. It's obviously being handled locally so I'll move on and continue my integration tests with the new controls.

Thanks for you time!

Paul
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Paul
Top achievements
Rank 1
Share this question
or