0
votes

I have a problem with my data binding from View to Controller

I have an object that includes 3 other objects that I want to pass from controller to view

ModelView { Product, PagingInfo, Filter }

So this is how it looks like from controller

public ViewResult List(ModelView mv, int page = 1) {

var viewModel = new ModelView() { ... }

return View(viewModel);

and the View looks like this

Inherit = "viewModel"

using(html.BeginForm()) { Html.EditorFor(x => x.Filter.Name) ... }

Questions are:

Am i right for binding ModelView as a parameter in the controller? or should I bind Filter instead?

When I used a debugger, it seemed like whatever I put in textfield (Html.editorfor) doesn't get binded back the controller

Please Help

Thanks

1

1 Answers

1
votes

My bad! It was working the entire time, I totally forgot that I put the default value as null in the routing system. Sorry for the trouble :(