I'm in a situation where I'm being given a dataset to output to an MVC view. I'm really struggling to figure out how to get the modelbinder to pick it up on the way back in after a submit. I have something like this...
public ActionResult TestData()
{
DataSet data = new DataSet("DS");
DataTable table = new DataTable("DT");
data.Tables.Add(table);
table.Columns.Add("ID", typeof (int));
table.Columns.Add("Name", typeof (string));
table.Rows.Add(1, "John");
table.Rows.Add(2, "Mark");
table.Rows.Add(3, "Paul");
table.Rows.Add(4, "Chris");
return View(data);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult TestData(DataSet data)
{
return View(data);
}
On the page I have tried lots of different naming schemes for the input elements but to no avail. Is this even possible. I would be using a viewmodel type if it were possible but unfortunately this is a completely dynamic structure and a dataset is the most natural thing to use.