Reputation: 1589
I have a webgrid via this code
@grid.GetHtml(
tableStyle: "webgrid",
columns: grid.Columns(
grid.Column(header: "Link", style: "labelcolumn", format: (item) => Html.ActionLink("Edit Item", "EditQueue", new { id = item.QueueID})),
grid.Column("Description", "Description"),
grid.Column("QueueDate", "QueueDate"),
grid.Column("Note", "Note"),
grid.Column("Status", "Status"),
grid.Column("LastUpdated", "LastUpdated")
)
)
I created a test case with ID 1. I then click the link in the first column. I get a 404 error because I haven't created a page for this at /Home/EditQueue/1
However I obviously don't want to create a page for each number. What is the best practice to create a page that just displays the ID I passed into it?
Upvotes: 0
Views: 210
Reputation: 218722
Create an action method which accepts the id
as parameter, in your HomeController
public ActionResult EditQueue(int id)
{
//Get the details of queue using id and return a view.
return View();
}
You probably want to show the data to edit. so get the data using the id and return that.
public ActionResult EditQueue(int id)
{
//Get the details of queue using id and return a view.
Queue queue=repositary.GetQueueFromID(id);
return View(queue);
}
Assuming repositary.GetQueueFromID
method will return a Queue
class object and your View (Edit.cshtml
) is strongly typed to that.
Upvotes: 1
Reputation: 9448
Just have your method with a parameter you are passing in the controller..
Upvotes: 0