MVC ASP.NET Getting my ViewData.Model in my View when I submit the controller

So, I am returning View (object); 'd and I hit submit on this page, how do I get this object back to the controller? any ideas?

my view page

public partial class Index : ViewPage<List<Models.Pricing>>

      

and

    public ActionResult Index(int id, FormCollection datesForm,
                             [Bind(Prefix="")]List<Pricing> model)
    {

        return View("Index", new{id});
    }

      

0


source to share


1 answer


Since you are really trying to get a list of models (like Pricing), you need to either develop your own IModelBinder, use it, or iterate through the collection of forms and pull the data for each scoring model from the parameters form and restore it. However, given your code, I don't understand why you need this.



Do you really want to get the model data associated with a given ID? Or is there more code than you showed? In the first case, your best bet is probably to repeat the request using the ID and not worry about additional parameters for the controller action.

+2


source







All Articles