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 all commits
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
56 changes: 56 additions & 0 deletions knowledge-base/grid-nullreferenceexception-gridrowcollection.md
@@ -0,0 +1,56 @@
---
title: NullReferenceException for GridRowCollection
description: How to fix a null reference exception thrown for the GridRowCollection property of the Telerik Blazor Grid.
type: troubleshooting
page_title: NullReferenceException for the Grid GridRowCollection
slug: grid-kb-nullreferenceexception-gridrowcollection
position:
tags:
ticketid: 1643250, 1642910, 1604815, 1574971, 1577863, 1580684
res_type: kb
---

## Environment
<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 and I get a `NullReferenceException` from the `GridRowCollection` class.

## Error Message

````
Error: System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Blazor.Components.Grid.GridRowCollection`1.BuildRenderTree(RenderTreeBuilder __builder)
````

## Cause

The Telerik UI Grid for Blazor throws a `NullReferenceException` for the `GridRowCollection` property when using both the `Data` parameter and `OnRead` event handler:

<div class="skip-repl"></div>

````CSHTML
<TelerikGrid Data="@GridData"
OnRead="@OnGridRead">
</TelerikGrid>
````

## Solution

Remove either the `Data` parameter or the `OnRead` event handler.

## See Also

* [Changes in the `OnRead` event in version 3.0]({%slug changes-in-3-0-0%}#onread)
* [Common `OnRead` event documentation]({%slug common-features-data-binding-onread%})
* [How to provide data to Telerik Blazor components]({%slug common-features-data-binding-overview%}#how-to-provide-data)