2

Hi I am Using Telerik MVC Grid Control in my MVC 3.0 Project

I am trying to add Additional Column to the Grid

  columns.Template(e =>
         @Html.ActionLink("Edit", "Action", "Controller",
         new { id = e.ID}, new { @class = "standard button" })
           );

This code is Creating an Additional Column But not displaying the Edit link in that column.

Can Any one Help me with this. How can make this work?

HaBo
  • 13,999
  • 36
  • 114
  • 206

1 Answers1

4

If you come from a WebForms (ASPX) ViewEngine world it can be a little confusing when working with column templates as traditionally you used to have to do columns.Template(e => .... );. However, with Razor we can now approach this a little differently. First of all, the usage of @ is embraced, so you don't need to use "e => ". Also, instead of having "e" we now can use the @item object which represents the entity tied to our Grid. So, this leaves us with the following snippet of code (which will produce the end-result you're looking for):

            columns.Template(
                @<text>
                    @(Html.ActionLink("Edit", "Action", "Controller", new { id = @item.ID }, new { @class = "standard button" }))
                </text>
            );
carlbergenhem
  • 1,989
  • 13
  • 12