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

[Solved] hyperlink display name but pass ID

2 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 13 Feb 2012, 07:08 PM
In my customer grid, I am interested in having the customer name as the hyperlink, but then pass the ID to open the edit window.  Here is my code so far using ElementAt that always opens record#1, but I was wondering I could get the current ElementAt or some other way to do this:

columns.Bound(c => c.CName).Width(165)
                        .Encoded(false)
                        .Format(Html.ActionLink("{0}", "Edit", new { id = Model.ElementAt(1).CustomerID }).ToHtmlString());

Thanks
Paul

2 Answers, 1 is accepted

Sort by
0
nachid
Top achievements
Rank 1
answered on 13 Feb 2012, 08:17 PM
columns.Bound(c => c.CName).Width(165)
                        .Encoded(false)
     .Template(@Html.ActionLink(item.Name, @"Edit"@"Customer"new { id = item.CustomerID }, null)
     .ClientTemplate(Html.ActionLink(<#=CName #>", "Edit""Customer"new { id = <#=CustomerID #>" }, null).ToHtmlString()
                          
0
Paul
Top achievements
Rank 1
answered on 13 Feb 2012, 09:27 PM
Thanks for the reply nachid:  I am rather new to this and need just a bit more clarification.  The .Template and .ClientTemplate are both complaining of the "item." being an unknown entity.  I tried c. but that is also an unknown entity in that position. I also am having trouble getting the closing parentheses in the right position. 

columns.Bound(c => c.CName).Width(165)

                        .Encoded(false)
     .Template(@Html.ActionLink(item.Name, @"Edit"@"Customer"new { id = item.CustomerID }, null)
     .ClientTemplate(Html.ActionLink(<#=CName #>", "Edit""Customer"new { id = <#=CustomerID #>" }, null).ToHtmlString()


Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
nachid
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Share this question
or