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

ElasticSearch / Tire & Keywords. Right way to match “or” for a keyword list?

ruby ruby-on-rails-3 elasticsearch

I've got an Entity model (in Mongoid) that I'm trying to search on its keywords field which is an array. I want to do a query where I pass in an array of potential search terms, and any entity that

Amazon InApp purchase still runs in Sandbox mode after the application is purchased

amazon-web-services in-app-purchase amazon

I published my app with Amazon AppStore, but InApp Testing library still has PurchasingService.IS_SANDBOX_MODE set to true.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.