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

ActionLink in ClientTemplate references databound data

1 Answer 99 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeremy Coenen
Top achievements
Rank 1
Jeremy Coenen asked on 20 Oct 2010, 05:56 PM
Basically I am trying to take the ClientExample, but rather than have hardcoded HTML in there I want to use the Html.ActionLink command, but am not sure how to reference the row data at that point to get the CustomerId for the routevalues.
<%= Html.Telerik().Grid<Customer>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.CustomerID)
                .ClientTemplate(Html.ActionLink("Customer","Edit", new {CustomerId = WanttoGetCustomerIdHere}).ToString())
                .Title("Picture");
            //omitted for brevity
        }
%>



http://demos.telerik.com/aspnet-mvc/grid/templatesclientside

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 21 Oct 2010, 06:48 AM
Hello Jeremy Coenen,

 This is not possible because Html.ActionLink is executed server side and does not have access to the client-side data item. Here is how to do it:

columns.Bound(c => c.CustomerID)
                .ClientTemplate(Html.ActionLink("Customer","Edit"new{CustomerId = "<#= CustomerID #>"}).ToString())

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
General Discussions
Asked by
Jeremy Coenen
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or