Red Swan
Red Swan

Reputation: 15545

value not getting from index view to controller method in asp.net mvc 2

As i showing the list of records in the index view in my asp.net mvc 2 + C# application. on the edit link, I am passing the string value which is the primary key in the db. so that I can access the respective records. but as i set the debugger at the controller in the Edit method , in parameter list I am not getting the value that I have passed. Scenario is like this :

INDEX : View

<%= Html.ActionLink("Edit", "Edit", new { id=item.CRNo }) %> 

In CONTROLLER:

public ActionResult Edit(String CRNo) // Here getting null
    {...some code...}

Where CRNo is string property of item.

Upvotes: 0

Views: 180

Answers (1)

Dan Dumitru
Dan Dumitru

Reputation: 5423

You are passing id as a parameter in the link, so you should read that.

public ActionResult Edit(string id)

Upvotes: 1

Related Questions