pzozulka
asked on
How to pass query string parameter with ActionLink in MVC
Below is my Razor syntax. I am trying to pass the s.StudentId via query string. The first <div> tag works fine, and I wanted to practice a little bit with ActionLink.
When the page loads in the browser, the links generated are:
1st div: http://localhost:57707/Students/Edit/?_studentId=1
2nd div: http://localhost:57707/Students/Edit?Length=8
What am I doing wrong inside the ActionLink, and why is it defaulting to Length=8?
When the page loads in the browser, the links generated are:
1st div: http://localhost:57707/Students/Edit/?_studentId=1
2nd div: http://localhost:57707/Students/Edit?Length=8
What am I doing wrong inside the ActionLink, and why is it defaulting to Length=8?
@foreach (Student s in studentList)
{
<div>@s.Email <a href="/Students/Edit/?_studentId=@s.StudentId">Edit</a></div> // Using query string to pass params
<div>@s.Email @Html.ActionLink("Edit", "Edit", "Students", new { _studentId = s.StudentId })</div>}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Should be
<div>@s.Email <a href="/Students/Edit?_stud
can you post controller method for Edit of student, I think you have a parameter name length over there.