This question is locked. New answers and comments are not allowed.
Hi, I saw there was solution to bind the dynamic objects to Grid, but I used the solution to bind, it threw exception.
Code:
Html.Telerik().Grid<dynamic>(Model.Select(n => new { n.ID, n.ItemID, n.Title, n.Name, n.VersionID }).ToList())
.Name("Grid")
.ToolBar(f => f.Position(GridToolBarPosition.Both).Custom().Action("Add", "TelerikNews", null).Text("Add"))
.Columns(columns =>
{
columns.Bound("ItemID");
columns.Bound("VersionID");
columns.Bound("Name");
columns.Bound("Title");
columns.Template(n =>
{
%>
<%=Html.ActionLink("Edit", "Edit", new { id = ( n as dynamic) .ID })%>
<%=Html.ActionLink("Delete", "Delete", new { id = (n as dynamic).ID }, new { onclick = "return confirm('Are you sure to delete this item?');" })%>
<%
});
})
.PrefixUrlParameters(false)
.DataBinding(c => c.Server())
.Pageable(g => g.PageSize(6)
.Position(GridPagerPosition.Both)
.Style(GridPagerStyles.Numeric))
.Sortable(sorting => sorting.SortMode(GridSortMode.MultipleColumn));
And the exception likes:
Exception Details: System.ArgumentException: Invalid property or field - 'ItemID' for type: Object
Source Error:
Source File: E:\Telerik.Web.Mvc\Infrastructure\Implementation\Expressions\MemberAccess\Tokenizer\MemberAccessTokenExtensions.cs Line: 28
Can anyone help me to explain what's wrong?
Thanks a lot.
Code:
Html.Telerik().Grid<dynamic>(Model.Select(n => new { n.ID, n.ItemID, n.Title, n.Name, n.VersionID }).ToList())
.Name("Grid")
.ToolBar(f => f.Position(GridToolBarPosition.Both).Custom().Action("Add", "TelerikNews", null).Text("Add"))
.Columns(columns =>
{
columns.Bound("ItemID");
columns.Bound("VersionID");
columns.Bound("Name");
columns.Bound("Title");
columns.Template(n =>
{
%>
<%=Html.ActionLink("Edit", "Edit", new { id = ( n as dynamic) .ID })%>
<%=Html.ActionLink("Delete", "Delete", new { id = (n as dynamic).ID }, new { onclick = "return confirm('Are you sure to delete this item?');" })%>
<%
});
})
.PrefixUrlParameters(false)
.DataBinding(c => c.Server())
.Pageable(g => g.PageSize(6)
.Position(GridPagerPosition.Both)
.Style(GridPagerStyles.Numeric))
.Sortable(sorting => sorting.SortMode(GridSortMode.MultipleColumn));
And the exception likes:
Invalid property or field - 'ItemID' for type: Object
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.ArgumentException: Invalid property or field - 'ItemID' for type: Object
Source Error:
|
Source File: E:\Telerik.Web.Mvc\Infrastructure\Implementation\Expressions\MemberAccess\Tokenizer\MemberAccessTokenExtensions.cs Line: 28
Can anyone help me to explain what's wrong?
Thanks a lot.