views:

160

answers:

1

I have an actionlink that on click im passing a List of objects to a controller action.

Example:

View:

Html.ActionLink("TestLink", "TestMethod", "Test", Model.SampleList, null)

TestController:

public ActionResult TestMethod(List<SampleList> sampleList)  
{  
  return View(sampleList);  
}

When I do this I get a null sampleList. I can pass a single complex object fine just not a collection of it. Do I need the correct routing for this? The reason I'm doing this is instead of passing an id and do a look up in the controller action, I just pass in the data.

+2  A: 

It is possible when you perform a form post, have a look at this blog post for more information. You'll probably not be able to use one of the HtmlHelper methods though, the post states:

Currently, we don’t have any helpers for generating the form, so this is a very manual process.

Nothing prevents you from writing your own helper though.

Thomas
Wow, you basically have to bind the model list to a form and post it. Cool thanks this explains it all.
Ying