This question is locked. New answers and comments are not allowed.
I'm attempting,and failing, to translate the MVC Grid client-side selection example from C# to VB.Net.
I keep getting an error when I run it "Bound columns require a field or property access expression.". The column definitions seems to be the issue but I'm at a loss to figure out why.
Here's the view source:
Controller source:
I keep getting an error when I run it "Bound columns require a field or property access expression.". The column definitions seems to be the issue but I'm at a loss to figure out why.
Here's the view source:
<%= Html.Telerik().Grid(Of IEnumerable(Of GridTest01.Customer))("Customers") _ .Name("Customers") _ .Columns(Sub(columns) columns.Bound(Function(c As GridTest01.Customer) c.CustomerID) columns.Bound(Function(c As GridTest01.Customer) c.CompanyName) columns.Bound(Function(c As GridTest01.Customer) c.ContactName) columns.Bound(Function(c As GridTest01.Customer) c.Country) End Sub) _ .DataBinding(Function(dataBinding) dataBinding.Ajax().[Select]("_SelectionClientSide_Customers", "Grid")) _ .Pageable() _ .Sortable() _ .Selectable() _ .ClientEvents(Function(events) events.OnRowSelect("onRowSelected")) _ .RowAction(Sub(row) Dim temp As GridTest01.Customer = row.DataItem.Cast(Of GridTest01.Customer)() 'row.Selected = row.DataItem.Cast(Of GridTest.Customer).CustomerID.Equals(ViewData("id")) row.Selected = temp.CustomerID.Equals(ViewData("id")) End Sub ) %><h3>Orders (<span id="customerID"><%= ViewData("id")%></span>)</h3><%= Html.Telerik().Grid(Of IEnumerable(Of GridTest01.Order))("Orders") _ .Name("Orders") _ .Columns(Sub(columns) columns.Bound(Function(c As GridTest01.Order) c.OrderID) columns.Bound(Function(c As GridTest01.Order) c.OrderDate).Format("{0:dd/MM/yyyy}") columns.Bound(Function(c As GridTest01.Order) c.ShipAddress) columns.Bound(Function(c As GridTest01.Order) c.ShipCity) End Sub) _ .DataBinding(Function(dataBinding) dataBinding.Ajax().[Select]("_SelectionClientSide_Orders", "Grid", New With { _ Key .customerID = "ALFKI" _ })) _ .Pageable() _ .Sortable()%>Controller source:
Imports Telerik.Web.Mvc<HandleError()> _Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As ActionResult ViewData("Message") = "Welcome to ASP.NET MVC!" Return View() End Function Public Function SelectionClientSide(ByVal id As String) As ActionResult ViewData("Customers") = GetCustomers() ViewData("Orders") = GetOrdersForCustomer(If(id, "ALFKI")) ViewData("id") = "ALFKI" Return View() End Function <GridAction()> _ Public Function _SelectionClientSide_Orders(ByVal customerID As String) As ActionResult customerID = If(customerID, "ALFKI") Return View(New GridModel(Of Order)() With { _ .Data = GetOrdersForCustomer(customerID) _ }) End Function <GridAction()> _ Public Function _SelectionClientSide_Customers() As ActionResult Return View(New GridModel(Of Customer)() With { _ .Data = GetCustomers() _ }) End Function Private Shared Function GetOrdersForCustomer(ByVal customerId As String) As IEnumerable(Of Order) Dim northwind As New NorthwindDataContext() Return From order In northwind.Orders Where order.CustomerID = customerId Select order End Function Private Shared Function GetCustomers() As IQueryable(Of Customer) Dim northwind As New NorthwindDataContext() Return northwind.Customers End Function Function About() As ActionResult Return View() End FunctionEnd Class