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

RadGrid Filter column getting Null Reference Error

4 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 05 Aug 2011, 08:43 PM
We have a RadGrid with multiple columns.  Two of the columns are Bound to some Lazy Loaded properties.

The first looks like this:

<telerik:GridBoundColumn DataField="Contact.FullName" DataType="System.String" FilterControlAltText="Filter Portfolio Manager column" HeaderText="Portfolio Manager" HeaderButtonType="TextButton" SortExpression="PortfolioManager" UniqueName="PortfolioManager" FilterControlWidth="60%">
     <HeaderStyle CssClass="GridHeaderControlColor" Width="25%" />
</telerik:GridBoundColumn>

The other looks like this:
<telerik:GridBoundColumn DataField="Contact1.Fullname" FilterControlAltText="Filter Compliance Officer column" SortExpression="ComplianceOfficer" HeaderText="Compliance Officer" HeaderButtonType="TextButton" UniqueName="ComplianceOfficer" DataType="System.String" FilterControlWidth="60%">
     <HeaderStyle CssClass="GridHeaderControlColor" Width="20%" />
</telerik:GridBoundColumn>


They are bound to different columns obviously but both are lazy loaded from the Contact table.

The first one (Portfolio Manager) Filters fine.

The second (Compliance Officer), when you Filter we get errors about Null Reference.
The error does not trigger any stoppage in Debug mode, it just goes straight back to the page and the Stack Trace doesn't touch any of our code.

I THINK the issue is that the second column can have NULLs, but I have no idea how to handle Null values on Lazy Loaded Bound objects.



Here is the Stacktrace:

[NullReferenceException: Object reference not set to an instance of an object.]
   lambda_method(Closure , PMD_ComplianceLoanAdminReport ) +62
   System.Linq.WhereEnumerableIterator`1.MoveNext() +141
   System.Linq.Enumerable.Count(IEnumerable`1 source) +225
   lambda_method(Closure ) +149
   System.Linq.EnumerableExecutor`1.Execute() +94
   System.Linq.EnumerableExecutor`1.ExecuteBoxed() +23
   System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +94
   Telerik.Web.UI.GridDynamicQueryable.Count(IQueryable source) +296
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +4216
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +1064
   Telerik.Web.UI.GridResolveEnumerable.Initialize() +58
   Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +45
   Telerik.Web.UI.GridResolveEnumerable.get_DataTable() +31
   Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +221
   Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +154
   Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +566
   Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +223
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +622
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +800
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   Telerik.Web.UI.GridTableView.PerformSelect() +38
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   Telerik.Web.UI.GridTableView.DataBind() +363
   Telerik.Web.UI.GridTableView.Rebind() +100
   Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source) +954
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +200
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +66
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +142
   Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument) +80
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +9998
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 11 Aug 2011, 08:12 AM
Hello James,

Data operations like filtering, sorting and data editing on nested properties is not supported in RadGrid. You need to provide names of immediate properties as DataField values for your columns. If you can modify your data objects or create a mapping to some custom data objects, you can map your nested properties as first level properties. RadGrid would then be able to use these fields in data calculations when sorting and filtering.

Greetings,
Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Daniel
Top achievements
Rank 1
answered on 20 Feb 2012, 05:15 PM
I received the same error that was result of having NULL value in a row of the field being filtered.  When I removed NULL value from database the filter worked fine.  I am not using nested properties.

 

 

<telerik:GridBoundColumn FilterControlAltText="Filter column1 column"

 

 

 

UniqueName="LastName" DataField="LastName" HeaderText="Last Name">

 

0
Veli
Telerik team
answered on 21 Feb 2012, 10:29 AM
Hello Daniel,

The scenario you are describing may or may not be related to the issue discussed in this thread. We need further info on your case, so that we can identify what's causing the exception at your side. If you can reproduce the issue in a simple runnable project you can send us, consider opening a regular support ticket where you can attach the project. Thus, we can test it locally and investigate what may be the problem.

Veli
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Bryan
Top achievements
Rank 1
answered on 06 Jul 2015, 05:58 AM

[quote]Veli said:Hello James,

Data operations like filtering, sorting and data editing on nested properties is not supported in RadGrid. You need to provide names of immediate properties as DataField values for your columns. If you can modify your data objects or create a mapping to some custom data objects, you can map your nested properties as first level properties. RadGrid would then be able to use these fields in data calculations when sorting and filtering.

Greetings,
Veli
the Telerik team

[/quote]

Is this still an issue in the 2015 versions of RadGrid? I'm using Q1 2015 SP1 ...

Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Veli
Telerik team
Daniel
Top achievements
Rank 1
Bryan
Top achievements
Rank 1
Share this question
or