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

Invalid property or field - '____' for type: String

3 Answers 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Derek Hunziker
Top achievements
Rank 1
Derek Hunziker asked on 08 Jul 2010, 09:25 PM
Hi all,

Anyone else come across this error? It occurs when I try to filter or sort any of my columns. I'm binding to Model.Users which is an IEnumberable<MembershipUser> collection...

<% Html.Telerik().Grid(Model.Users)
               .Name("grid")
               .Columns(columns =>
               {
                   columns.Bound(user => user.UserName);
                   columns.Bound(user => user.Email);
                   columns.Bound(user => user.Comment);
               }).Pageable().Sortable().Filterable().Render();
%>

[ArgumentException: Invalid property or field - 'UserName' for type: String]
   Telerik.Web.Mvc.Infrastructure.Implementation.Expressions.MemberAccessTokenExtensions.CreateMemberAccessExpression(IMemberAccessToken token, Expression instance) +162
   Telerik.Web.Mvc.Infrastructure.Implementation.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName) +111
   Telerik.Web.Mvc.Infrastructure.Implementation.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpression() +70
   Telerik.Web.Mvc.Infrastructure.Implementation.Expressions.MemberAccessExpressionBuilderBase.CreateLambdaExpression() +17
   Telerik.Web.Mvc.Infrastructure.Implementation.SortDescriptorCollectionExpressionBuilder.Sort() +125
Telerik.Web.Mvc.Extensions.QueryableExtensions.ToGridModel(IQueryable queryable, Int32 page, Int32 pageSize, IList`1 sortDescriptors, IEnumerable`1 filterDescriptors, IEnumerable`1 groupDescriptors) +387
Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() +141
Telerik.Web.Mvc.UI.GridDataProcessor.get_PageCount() +13

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Jul 2010, 07:15 AM
Hi Derek Hunziker,

We have not seen this problem before. Is there anything special in this property? This exception can be thrown if this is not a field or property at all.

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
Derek Hunziker
Top achievements
Rank 1
answered on 13 Aug 2010, 05:13 PM
I think I may have found the cause of this...

I have two grids on the page. My model contains two parts: an IEnumerable<MembershipUser> and an IEnumerable<string>. The first grid is bound to the MembershipUsers and the second grid is bound to the strings. When I try and sort or filter the MembershipUser grid, the error above gets thrown.

The exception bubbles up at the definition for the second grid, so I suspected it was the second grid causing the issues. Sure enough, removing the second grid fixes everything and I can sort and filter the first grid just fine.

What's interesting is that the error complains that 'UserName' is the invalid property or field, but that second grid is not bound to MembershipUser... it's only a list of strings.

Any ideas on what I'm doing wrong here? I can provide a sample project if needed.

Thank you!
0
Pius
Top achievements
Rank 1
answered on 08 Jan 2012, 04:50 AM
I had exactly the same problem using 2 grid and Sorting. -> I figured out what causes the Problem.

I used the Name "Gird" twice.

@(Html.Telerik().Grid(Model.DinnerGuests)
        .Name("Grid")
etc.............


@(Html.Telerik().Grid(Model.DinnerGuestOverviewItems)
        .Name("Grid")
etc.............

Rename the seconde grid to .Name("OverviewGrid") solved the Problem for me. Sorting works again.
Tags
Grid
Asked by
Derek Hunziker
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Derek Hunziker
Top achievements
Rank 1
Pius
Top achievements
Rank 1
Share this question
or