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.
[HttpPost]
public ActionResult Details(FormCollection Collection)
{
try
{
foreach (var item in Collection)
{
//TODO set up form values container for populating new object
string test = Collection[item.ToString()];
}
Assembly CurrentAssembly =
Assembly.GetExecutingAssembly();
dynamic updateObject = CurrentAssembly.CreateInstance("Employee");