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?
Create an action method which accepts the
idas parameter, in your HomeControllerYou probably want to show the data to edit. so get the data using the id and return that.
Assuming
repositary.GetQueueFromIDmethod will return aQueueclass object and your View (Edit.cshtml) is strongly typed to that.