MVC ASP.NET Getting back my ViewData.Model in my View when I submit to a Controller

So I've return View(object);'d, and I press submit on that page, how do I get that object back in the controller? any ideas?

my viewpage is

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});
    }

Answers


Because you are really trying to retrieve a list of models (of type Pricing), you will either need to develop a custom IModelBinder and use it or iterate through the form collection and pull the data for each pricing model out of the form parameters and reconstitute them. Given your code, though, I don't see why you need to do this.

Is it really the case that you want to get the model data associated with the given id? Or is there more code than what you've shown? In the former case, the best thing to do is probably re-run the query using the id and not bother with the extra parameters to the controller action.


Need Your Help

Connection pool connections consumed when in TransactionScope

sql-server-2008 linq-to-sql connection-pooling transactionscope

Can someone explain why we are experiencing a total consumption of the connection pool when performing queries inside TransactionScope resulting in

WPF DataGrid how to get when ItemsSource updates

wpf events datagridview wpf-controls wpfdatagrid

Which event fires when DataGrid's source is updating? I've tried DataContextChanged and SourceUpdated but it never worked out.