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

Bound Grid Collection Cleared NullReferenceException in TypeExtensions.DefaultValue

5 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Leslie
Top achievements
Rank 1
Leslie asked on 03 Nov 2010, 08:51 PM
I have a grid bound to a collection.  If I invoke something that removes all of the items in the collection, I get a null reference exception with the following call stack, which does not contain any of my code.   I get this error 3 times and I had 3 items in my collection.  Any thoughts?

Leslie

<ce:CmpDataGrid Grid.Row="1" x:Name="dgCost" AutoGenerateColumns="False"  ItemsSource="{Binding bocCurrentCosts}"
    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SelectionMode="Single"
    ToolStrip="{Binding ElementName=tsCost}" IsFilteringAllowed="False">
    <ce:CmpDataGrid.Columns>
    <ce:CmpGridViewDataColumn DataMemberBinding="{Binding vendordcname, Mode=TwoWay}" Header="{Binding LStrings._VendorDC, Source={StaticResource Strings}}" IsReadOnly="True" />
    <ce:CmpGridViewDataColumn UniqueName="package" Header="{Binding LStrings._Package, Source={StaticResource Strings}}" IsReadOnly="True" >
    <ce:CmpGridViewDataColumn.CellTemplate>
    <DataTemplate>
        <Grid MinWidth="150">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding PackageDescription, Mode=OneWay}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center" />
            <Button Grid.Column="1" x:Name="btnFindPackage" VerticalAlignment="Stretch" Click="btnGridFindPackage_Click" Visibility="{Binding IsNewDC, Converter={StaticResource myBoolVisibleConverter}}" ToolTipService.ToolTip="{Binding LStrings._ItemPackageToolTip, Source={StaticResource Strings}}">
                <Image Source="/Repeat.Common.Controls;component/Assets/SymbolSearch.png" />
            </Button>
        </Grid>
    </DataTemplate>
    </ce:CmpGridViewDataColumn.CellTemplate>
    </ce:CmpGridViewDataColumn>
    <ce:CmpGridViewDataColumn DataMemberBinding="{Binding effectivedate, Mode=TwoWay}" Header="{Binding SStrings._BeginDate, Source={StaticResource Strings}}" IsVisible="{Binding IsNewDC, Converter={StaticResource myNotConverter}}" IsReadOnly="True" />
    <ce:CmpGridViewDataColumn UniqueName="uomcost" DataMemberBinding="{Binding uomcost, Mode=TwoWay}" Header="{Binding LStrings._Cost, Source={StaticResource Strings}}"  IsReadOnlyBinding="{Binding IsNewDC, Converter={StaticResource myNotConverter}}" DataFormatString="{}{0:c}" MinWidth="75"/>
    </ce:CmpDataGrid.Columns>
</ce:CmpDataGrid>


> Telerik.Windows.Data!Telerik.Windows.Data.TypeExtensions.DefaultValue(System.Type type = null) + 0x1a bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.ExpressionFactory.DefaltValueExpression(System.Type type = null) + 0x20 bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(System.Linq.Expressions.Expression instance = null, string memberName = "package", System.Type memberType = null) + 0xa3 bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(System.Linq.Expressions.Expression instance = {System.Linq.Expressions.TypedParameterExpression}, string memberName = "package", System.Type memberType = null, bool liftMemberAccessToNull = true) + 0x30 bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpressionOverride() + 0x6d bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateMemberAccessExpression() + 0x59 bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateLambdaExpression() + 0x2b bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.BindingToExpressionExtensions.CreateMemberAccessLambdaExpression(System.Windows.Data.Binding binding = {System.Windows.Data.Binding}, System.Type objectType = {System.RuntimeType}, System.Type memberType = null) + 0x7a bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.BindingToExpressionExtensions.CreateUntypedMemberAccessFunc(System.Windows.Data.Binding binding = {System.Windows.Data.Binding}, System.Type objectType = {System.RuntimeType}, System.Type memberType = null) + 0x4c bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.BindingToExpressionExtensions.CreateMemberAccessFunc(System.Windows.Data.Binding binding = {System.Windows.Data.Binding}, System.Type objectType = {System.RuntimeType}, System.Type memberType = null) + 0x30 bytes 
  Telerik.Windows.Data!Telerik.Windows.Data.DataFieldDescriptorExtensions.CreateMemberAccessFunc(Telerik.Windows.Data.IDataFieldDescriptor fieldDescriptor = {Repeat.Common.Controls.CmpGridViewDataColumn}) + 0x7e bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridViewBoundColumnBase.InitializeMemberAccessFunc() + 0x2e bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridViewBoundColumnBase.MemberAccessFunc.get() + 0x29 bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridViewBoundColumnBase.GetCellContent(object item = {Repeat.Library.ceEdtCurrentVendorItemCostsBO}) + 0x2c bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewCell.UpdateCellValue() + 0x7f bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewRow.ProcessDataItemPropertyChanged(string propertyName = "") + 0x87 bytes 
  Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewRow.Telerik.Windows.Data.IWeakEventListener<System.ComponentModel.PropertyChangedEventArgs>.ReceiveWeakEvent.AnonymousMethod__1b() + 0x6e bytes 
  [Native to Managed Transition] 
  [Managed to Native Transition] 
  mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x76 bytes 
  mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0xb bytes 
  System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0x2b bytes 
  System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) + 0xcc bytes 
  System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) + 0xa bytes 
  System.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) + 0x16 bytes 
  System.Windows.Browser.dll!System.Windows.Hosting.ScriptingInterface.InvokeDelegate(System.Windows.Hosting.DelegateWrapper delegateWrapper, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult = {System.Windows.Hosting.NativeMethods.ScriptParam}) + 0x28 bytes 
  System.Windows.Browser.dll!System.Windows.Hosting.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult) + 0xe3 bytes 
  [Appdomain Transition] 

5 Answers, 1 is accepted

Sort by
0
Leslie
Top achievements
Rank 1
answered on 03 Nov 2010, 09:09 PM
Some additional information, if I remove the column with the cell template, I don't get the error!  If I pare it down to the folliwing, I still get the error.  If I remove the unique name, I don't!

<telerik:GridViewDataColumn UniqueName="package" >
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
0
Vlad
Telerik team
answered on 04 Nov 2010, 08:47 AM
Hi Leslie,

Can you post more info about the grid version? I see that you do not have DataMemberBinding declared for this column - maybe it will be better to use GridVewColumn instead if you want only templates.

Sincerely yours,
Vlad
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
Leslie
Top achievements
Rank 1
answered on 05 Nov 2010, 04:03 PM
The Telerik.Windows.Controls.GridView.dll version number is 2010.2.924.1040

Don't I have to use a GridViewDataColumn if the items in the template need to be bound?

I was able to get around the problem by removing the UniqueName and adding
DataMemberBinding="{Binding PackageDescription, Mode=TwoWay}" 

But it still seems like UniqueName should work.

Leslie
0
Seth
Top achievements
Rank 1
answered on 29 Feb 2012, 06:45 AM
Has this been resolved?  I am having a similar issue.

Thanks,
Seth
0
Vlad
Telerik team
answered on 29 Feb 2012, 08:16 AM
Hello Seth,

 Indeed we believe that this is fixed long time ago.

All the best,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Leslie
Top achievements
Rank 1
Answers by
Leslie
Top achievements
Rank 1
Vlad
Telerik team
Seth
Top achievements
Rank 1
Share this question
or