We'll begin enabling our application's Edit functionality by
implementing the ProductController's Edit action method. When we created
our product listing page at the beginning of this post, we built it so that the
Edit action will take an id argument as part of the URL (for example:
/Products/Edit/5):
Figure 33
We'll want the Edit action method to retrieve
the appropriate Product object from the database, as well as retrieve
collections of the available Suppliers and Categories (so that we can implement
dropdowns in our edit view). We'll define a strongly typed view object to
represent all of this using the ProductsEditViewData object below:
Figure 34
We can then implement our Edit action method
to populate this viewdata object and Render it with an "Edit" view:
Figure 35