Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a KB on null reference exception from the GridRowCollection class #2006

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions knowledge-base/grid-rowcollection-nullreference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
title: Null Reference Expection from the GridRowCollection
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
description: Fixing a Null Reference Exception Thrown from the GridRowCollection.
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
type: troubleshooting
page_title: Null Reference Expection from the GridRowCollection
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
slug: grid-kb-nullref-gridrowcollection
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
position:
tags:
ticketid: 1643250, 1642910, 1604815, 1574971, 1577863, 1580684
res_type: kb
---

## Environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the issue is version-related, you can add the affected versions to the table. In this case, they are "3.0.0 and later".

<table>
<tbody>
<tr>
<td>Product</td>
<td>Grid for Blazor</td>
</tr>
</tbody>
</table>


## Description

I upgraded the version of the Telerik UI from Blazor components from `<3.0.0` to `>3.0.0` and I get a `NullReferenceException` from the `GridRowCollection` class.
svdimitr marked this conversation as resolved.
Show resolved Hide resolved

## Error Message

>warning Error: System.NullReferenceException: Object reference not set to an instance of an object.
dimodi marked this conversation as resolved.
Show resolved Hide resolved
at Telerik.Blazor.Components.Grid.GridRowCollection`1.BuildRenderTree(RenderTreeBuilder __builder)

## Cause

The Telerik Grid for Blazor throws a NullReferenceException from the GridRowCollection class when both the `Data` paramater and `OnRead` event handler are defined:
svdimitr marked this conversation as resolved.
Show resolved Hide resolved

````CSHTML

<TelerikGrid Data="@DataCollection" OnRead="@OnReadHandler">
...
</TelerikGrid>
````
svdimitr marked this conversation as resolved.
Show resolved Hide resolved

## Solution

Remove either the `Data` parameter or the `OnRead` event handler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the developer has used OnRead for some reason, it's unlikely they will go back to Data. Thus the primary recommendation can be phrased in a different way. For example, focus on the new way to use OnRead and link the relevant documentation here. The "See Also" links are less visible by definition.


## See Also

* [Changes in the OnRead Event in 3.0.0]({%slug changes-in-3-0-0%}#onread)
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
* [Common OnRead Documentation]({%slug common-features-data-binding-onread%})
svdimitr marked this conversation as resolved.
Show resolved Hide resolved
* [Common How to Provide Data Documentation]({%slug common-features-data-binding-overview%})
svdimitr marked this conversation as resolved.
Show resolved Hide resolved