Question

I'm trying to implement a simple listview / detailview feature in one of our apps. I'm using the MVCContrib Grid (which btw is awesome!) to show the list of items. There's an edit link next to every row on the grid that allows the user to edit the item. When the users click the edit link I execute a Get that returns the details form used to editing the item. For some reason I cannot get the clicked customerId to be sent to the controller. The controller just gets null every time I click the edit link.

My grid is configure like so:

  Html.Grid(Model.CheckAccounts)
    .Columns(column.For(c => {Html.ActionLink(
    "Edit", 
    "CustomerDetails", 
    "CustomerManagementController", 
    new {Id=customer.Id}));
column.For(c => c.Name);
column.For(a => c.AccountNumber);
}).Render();

Here's My controller Action:

  [HttpGet]
        public ActionResult CustomerDetails(long? Id )
        {
            //fetch the customer from repo...
            //return it to the client
            return View(model);
        }

I'm totally confused since all the samples and blogs I've seen, access data from the grid the same way I'm doing it. Can someone help?

Était-ce utile?

La solution

I hate to answer my own question but I was able to fix this by changing the action link to:

{Html.ActionLink(
        "Edit", 
        "CustomerDetails", 
        "CustomerManagement", 
        new {Id=customer.Id}));

I realized the wrong action link was being generated after looking at the "?Length=24" queryString parameter at the end of the URL.

The grid is working as expected now.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top