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

ClientRowTemplate with Html.ActionLink that has ID in the path

2 Answers 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HSO
Top achievements
Rank 2
HSO asked on 09 Apr 2013, 02:57 PM
Hello:

@(Html.Kendo().Grid<projectInfoViewModel>()
.Name("grid2")
.Columns(cols =>
{
    cols.Bound(e => e.OrgID).Tital("View Detail").Template(e => { }).ClientTemplate(" ");
    cols.Bound(e => e.OrgName).Title("Organization");
})
.DataSource(dataSource => dataSource
.Ajax()
                 .Read(read => read.Action("Index", "Summary"))
    )
     .ClientRowTemplate(
            "<tr>" +
                "<td>" +
                       @Html.ActionLink("#: OrgID#", "Index", "Info", new orgViewModel { oID = int.Parse("#: OrgID#"), uID = int.Parse("#: UserID#") }, null) +
                "</td>" +
                "<td>" +
                    "#: City #<br/>" +
                   "#: ProvinceText#<br/>" +
                    "#: CountryText# " +
                "</td>" +                
             "</tr>"
        )  
 )

I'd like to format the 1st column as Hyperlinks like: <a href="~/Info/Index?oID=999&uID=22">999</a>

however, i am having problem assign value to RouteValue:
new orgViewModel { oID = int.Parse("#: OrgID#"), uID = int.Parse("#: UserID#") }

oID and uID are both int, if I don't have int.parse(), it will complain that 'Cannot implicitly convert type 'string' to 'int'', I've tried Convert.ToInt32(), Int32.Parse(), int.Parse() all give error: Input string was not in a correct format. 

Please advise,
Thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 10 Apr 2013, 12:32 PM
Hi Jason,


I would suggest you the following workaround - pass some kind of a placeholder to the Html.ActionLink method and then replace it with the hash syntax values. Here is a sample implementation:
E.g.
@Html.ActionLink("#: OrgID#", "Index", "Info", new orgViewModel { oID = "OrgID", uID = "UserID" }, null).ToHtmlString().Replace("OrgID", "#=OrgID#").Replace("UserID", "#=UserID#")

I hope this approach will work in the current scenario.

 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
HSO
Top achievements
Rank 2
answered on 12 Apr 2013, 03:48 PM
Thank you, that works!
Tags
Grid
Asked by
HSO
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
HSO
Top achievements
Rank 2
Share this question
or