This is a migrated thread and some comments may be shown as answers.
Bug: Grid throws NullReferenceException if Name is not specified
2 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roger Lipscombe
Top achievements
Rank 1
Roger Lipscombe asked on 01 Apr 2011, 02:19 PM
@(Html.Telerik().Grid(Model.Orders)
    .Columns(columns => { /* etc. */ })

causes the following stack trace:

[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.Mvc.UI.ViewComponentBase.get_Id() +182 Telerik.Web.Mvc.UI.Grid`1.Prefix(String parameter) +58 Telerik.Web.Mvc.UI.GridBindingContextExtensions.GetGridParameter(IGridBindingContext context, String key) +55 Telerik.Web.Mvc.UI.GridDataProcessor.get_GroupDescriptors() +75 Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() +133 Telerik.Web.Mvc.UI.GridDataProcessor.get_ProcessedDataSource() +29 Telerik.Web.Mvc.UI.Grid`1.CreateRenderingData() +381 Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +1237

It's caused by missing out the Name:

@(Html.Telerik().Grid(Model.Orders)
    .Name("Orders")
    .Columns(columns => {

The exception should be more user-friendly.

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Apr 2011, 04:31 PM
Hello Roger Lipscombe,

 Thank you for reporting this problem. We will fix it in our next official release.
 

Regards,
Atanas Korchev
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
Nick
Top achievements
Rank 1
answered on 02 May 2011, 06:01 PM
Thanks for your post, I just came across the same problem and found your solution to stop this Exception from happening. I agree, throwing a generic Null Reference exception for this is pretty annoying, and doesn't tell you at all what is causing it.
Tags
Grid
Asked by
Roger Lipscombe
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Nick
Top achievements
Rank 1
Share this question
or