In my latest project I have to use strongly typed DataSets. I have a problem submit a form to a POST controller: I get an parameterless constructor error i.e. it does not found the OrderCreate post method on controller. I will appriciate any help. Thank you.
Here is my simplified code:
View:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyPortal.Models.MyTypedDataRow >" %>
<% using (Html.BeginForm("OrderCreate", "Order", FormMethod.Post))
{%>
<%: Html.ValidationSummary(true)%>
<fieldset>
<legend>Fields</legend>
<p class="fields">
<%: Html.Label("Customer")%>
<%: Html.TextBoxFor(model => model.CustomerName)%>
<%: Html.ValidationMessageFor(model => model.CustomerName)%>
</p>
<p>
<input type="submit" value="Add" />
</p>
</fieldset>
<% } %>
Controllers:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult OrderCreate()
{
MyTypedDataTable table = new MyTypedDataTable ();
MyTypedDataRow row = table.NewMyTypedDataRow();
return PartialView(row);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult OrderCreate(FormCollection coll, MyTypedDataRow row)
{
int result = m_repo.InsertGI(row);
if (result > 0)
{
return RedirectToAction("OrderList");
}
else
{
return View("Error");
}
}