dennitorf
dennitorf

Reputation: 319

client template kendo ui asp net mvc

I have a grid with a Client_Name column, but I want pass the ID to another view, an put the link to this view in the Client_Name column.

In the next instruction, how I can set to ITEM_ID the value of the ID in the row.

columns
.Bound(e => .Desc_Cliente)
.Width(120)
.Groupable(false)
.Title("Descripcion")
.ClientTemplate("<a href='" + Url.Action("ClientProfile_GeneralData", "CrmCProfile", new { Id_Cliente = ITEM_ID }) + "/#= Id_Cliente #'" + ">#= Desc_Cliente #</a>");

Thanks.

Upvotes: 0

Views: 6753

Answers (1)

jwatts1980
jwatts1980

Reputation: 7346

Use the #: # notation:

columns
.Bound(e => .Desc_Cliente)
.Width(120)
.Groupable(false)
.Title("Descripcion")
.ClientTemplate("<a href='" + Url.Action("ClientProfile_GeneralData", "CrmCProfile", new { Id_Cliente = "#: Id_Cliente #" }) + "'>#= Desc_Cliente #</a>");

Even though the ID may not be a string, don't forget that the Url.Action converts the whole thing into a string anyway. MVC will take care of the casting internally.

Another way to do this is with the @Html.ActionLink helper:

.ClientTemplate(
    @Html.ActionLink("#= Desc_Cliente #", "ClientProfile_GeneralData", "CrmCProfile", 
        new { Id_Cliente = "#: Id_Cliente #" }, 
        null
    ).ToHtmlString()
)

For what it's worth, I haven't figured out yet the difference between #: # and #= #. Either one seems to work.

Upvotes: 1

Related Questions