C# – Generic object controller in MVC, can you improve the code


I am creating an application that will display a list of objects in a datagrid (list of any type of object), and allow the user to update any item. The code will know nothing about the object being displayed until runtime. Can you improve my code for the update? I am using Formcollection to get items from the form and creating an instance of my class based on the Routing info, ie it will pull out the object (hardcoded Employee for this example) from URL and create an instance of it.

public ActionResult Details(FormCollection Collection)    
                foreach (var item in Collection)
                   //TODO set up form values container for populating new object 
                   string test = Collection[item.ToString()];
                 Assembly CurrentAssembly =
                dynamic updateObject = CurrentAssembly.CreateInstance("Employee");

Best Solution

Have a look at ModelVisualizer in MVCContrib. It can display a collection of objects. You could start from there.