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

[Solved] Errors occuring when upgrading MVC Grid from MVC1 to MVC2 in VS 2010?

1 Answer 89 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.
Nick Pepper
Top achievements
Rank 1
Nick Pepper asked on 04 Aug 2010, 12:34 PM
Hi Telerik

I'm currently upgrading my MVC project from Visual Studio 2008 to 2010 and from MVC 1 to MVC 2. I'm using VB.NET and was using the 2010.1.309 MVC 2 release which i have upgraded to 2010.1.329 MVC 2 release. In both these telerik builds i get the following error message when the MVC grid trys to render on the page:

Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.


Line 56: Dim colContractId As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.ID)

I have read the telerik forum post that discusses the issue but i am unable to apply the work around to the VB example below. Could some one please give me an example of how to get the below MVC grid rendering code to work in VB and MVC 2?

Many thanks

Nick

<%                                                            
     Dim grid As Telerik.Web.Mvc.UI.Grid(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel) = Html.Telerik.Grid(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel) _
    .Name("ContractGrid") _
    .Sortable() _
    .Pageable(Function(p) p.Total(CInt(ViewData("Total")))) _
    .Filterable() _
    .Selectable() _
    .EnableCustomBinding(True) _
    .ClientEvents(Function(events) events.OnRowSelected("onRowSelected")) _
    .DataBinding(Function(d) d.Ajax().Select("GetContracts", "Contracts"))
     grid.Paging.PageSize = 20
     Dim colContractId As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.ID)
     Dim colContractName As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.ContractName)
     Dim colPORef As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.PORef)
     Dim colClient As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.Client)
     Dim colClients As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.Clients)
     Dim colCurrentStatus As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, Attenda.CMDBExtensions.Contracts.ContractStatus)(grid, Function(c) c.ContractStatus)
     Dim colStartDate As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.StartDate)
     Dim colEndDate As New Telerik.Web.Mvc.UI.GridBoundColumn(Of Attenda.CMDBExtensions.Contracts.ContractsSummaryViewModel, String)(grid, Function(c) c.EndDate)
     colCurrentStatus.Title = "Current Status"
     colClient.Title = "Contract Owner"
     colContractId.Sortable = False
     colContractId.Filterable = False
     colStartDate.Sortable = True
     colEndDate.Sortable = True
     grid.Columns.Add(colContractId)
     grid.Columns.Add(colContractName)
     grid.Columns.Add(colPORef)
     grid.Columns.Add(colClient)
     grid.Columns.Add(colClients)
     grid.Columns.Add(colCurrentStatus)
     grid.Columns.Add(colStartDate)
     grid.Columns.Add(colEndDate)
     grid.Render()
   %>

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 04 Aug 2010, 12:58 PM
Hi Nick Pepper,

Unfortunately the provided source code does not indicate what the problem may be. This exception will be thrown if anything but member expression (field or property access) is used when defining a bound column. The code you pasted does not seem to have any of those but I cannot be sure without seeing how the ViewModel object looks like. I suggest you open a support ticket and attach a sample project.

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
Tags
Grid
Asked by
Nick Pepper
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or