We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error No parameterless constructor defined for this object

I am recieve the following error when I attempt to use the GridEditMode.ExternalForm editting mode:

No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

Source Error:

Line 123:
Line 124: <div class="mc-grid" style="width:50.6em">
Line 125: <%= Html.Syncfusion().Grid<UserModel>("TestUsers")
Line 126: .Datasource(Model.SearchResults)
Line 127: .Caption("Users")
Source File: c:\UID\AMC\UIDWebSite\Views\Account\TestUsers.aspx Line: 125

Stack Trace:

[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance() +103
Syncfusion.Mvc.Grid.GridValidatorHtmlBuilder`2.RenderValidationHelpers(GridColumn`1 col, HtmlHelper helper) +41
Syncfusion.Mvc.Grid.<>c__DisplayClass17.<RenderEditForm>b__16(GridColumn`1 column) +96
Syncfusion.Linq.FunctionalExtensions.ForEach(IEnumerable`1 items, Action`1 action) +151
Syncfusion.Mvc.Grid.GridEditRenderer`1.RenderEditForm() +392
Syncfusion.Mvc.Grid.GridEditRenderer`1.GetEditForms() +580
Syncfusion.Mvc.Grid.Grid`1.InitializeEditing(HtmlTag grid) +119
Syncfusion.Mvc.Grid.Grid`1.CreateGrid() +118
Syncfusion.Mvc.Grid.GridBuilder`1.Render() +279
Syncfusion.Mvc.Grid.GridBuilder`1.ToString() +5
System.Web.HttpWriter.Write(Object obj) +27
System.Web.Mvc.SwitchWriter.Write(Object value) +15
System.Web.UI.HtmlTextWriter.Write(Object value) +37
ASP.views_account_testusers_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in c:\UID\AMC\UIDWebSite\Views\Account\TestUsers.aspx:125
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\UID\AMC\UIDWebSite\Views\Shared\Site.Master:35
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +56
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

The following code is from my View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AMCMarking.Models.GetUsersModel>" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>
<%@ Import Namespace="AMCMarking.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Search Users

<asp:Content ID="Content3" ContentPlaceHolderID="MenuContent" runat="server">

<nav>
<ul class="sf-menu">

<% if (System.Web.HttpContext.Current.Session["UserName"] != null)
{ %>
<li> <%: Html.ActionLink("Home", "Index", "Home")%>
<li> <%: Html.ActionLink("Search People", "SearchPerson", "Person")%>
<li> <%: Html.ActionLink("Add People", "AddPerson", "Person", null, new { Id = "AddPersonMenu" })%>
<li class="current">
<a>Admin</a>
<ul id="admin">
<% if (System.Web.HttpContext.Current.Session["RoleName"].ToString().ToUpper() == "ADMINISTRATOR")
{ %>
<li class="current"><%: Html.ActionLink("Users", "Users", "Account")%>
<% }
else { %>
<li class="current"><%: Html.ActionLink("User", "EditUser", "Account", new { UserID = Html.AttributeEncode(System.Web.HttpContext.Current.Session["UserID"]) }, null)%>
<% } %>
</ul>

<% }
else
{ %>
<li class="current">
<li> <%: Html.ActionLink("Home", "Index", "Home")%>

<% } %>
<li><%: Html.ActionLink("About", "About", "Home")%></li> </ul>
</nav>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

Search Users


<% using (Html.BeginForm()) { %>
<%: Html.ValidationSummary(true, "User search was unsuccessful.") %>

<fieldset>
<legend>User Search Parameters</legend>

<table>
<tr>
<th> <%: Html.LabelFor(m => m.UserName) %></th>
<th> <%: Html.LabelFor(m => m.Roles)%></th>
<th> <%: Html.LabelFor(m => m.IsApproved)%></th>
<th></th>
</tr>
<tr>
<td>

<%: Html.ValidationMessageFor(m => m.UserName) %>

<%: Html.TextBoxFor(m => m.UserName) %>
</td>
<td>

<%: Html.ValidationMessageFor(m => m.Roles)%>

<%: Html.DropDownList("RoleListClass", (SelectList)ViewData["rolelist"], new { style = "width:150px;" })%>
</td>
<td>

<%: Html.ValidationMessageFor(m => m.IsApproved)%>

<%: Html.DropDownList("IsApprovedListClass", (SelectList)ViewData["isapprovedlist"], new { style = "width:75px;" })%>
</td>
</tr>

<tr>
<th> <%: Html.LabelFor(m => m.LastName) %></th>
<th> <%: Html.LabelFor(m => m.FirstName) %></th>
<th> <%: Html.LabelFor(m => m.MiddleName)%></th>
</tr>
<tr>
<td>

<%: Html.ValidationMessageFor(m => m.LastName) %>

<%: Html.TextBoxFor(m => m.LastName, new { style = "width:14em" })%>
</td>
<td>

<%: Html.ValidationMessageFor(m => m.FirstName) %>

<%: Html.TextBoxFor(m => m.FirstName, new { style = "width:13.3em" })%>
</td>
<td>

<%: Html.ValidationMessageFor(m => m.MiddleName)%>

<%: Html.TextBoxFor(m => m.MiddleName, new { style = "width:13em" })%>
</td>
</tr>
</table>

<input type="submit" value="Search" />    
<input type="button" id="UserBiometricSearch" class="myButton" value="Biometric Search" />

<%: Html.LabelFor(m => m.SearchResults)%>



<%= Html.Syncfusion().Grid<UserModel>("TestUsers")
.Datasource(Model.SearchResults)
.Caption("Users")
.Column(cols =>
{
cols.Add(m => m.UserName);
cols.Add(m => m.LastName);
cols.Add(m => m.FirstName);
cols.Add(m => m.MiddleName);
cols.Add(m => m.Role);
cols.Add(m => m.IsApproved);
cols.Add(m => m.IsLockedOut);
})
.ToolBar(tool =>
{
tool.Add(GridToolBarItems.Search)
.Add(GridToolBarItems.Edit)
.Add(GridToolBarItems.Delete);< })
.Mappers(mapper =>
{
mapper.DeleteAction("JSONDelete");
})
.Editing( edit=>{
edit.ExternalForm(ef =>
{
ef.TargetID("TestUser");
ef.Position(ExternalFormPosition.BottomLeft);
});
edit.AllowDelete(true)
.AllowEdit(true);
edit.EditMode(GridEditMode.ExternalForm);
edit.ExternalModeEditorTemplate("EditUser");
edit.PrimaryKey(key => key.Add(m => m.UserID));

})
.ActionMode(ActionMode.JSON)
.AutoFormat(Skins.Blueberry)
.EnableSorting()
.AllowSearching(true)
.EnableFiltering()
.EnablePaging().SortSettings(sort => { sort.AllowMultiSorting(true); })
%>


</fieldset> <input type="hidden" name="BiometricWSURL" value="<%= System.Web.HttpContext.Current.Session["BiometricWSURL"] %>" id="BiometricWSURL" />
<%: Html.Hidden("PersonIDString", "")%>



<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript">
<script src="<%: Url.Content("~/Scripts/javascript_hitvein.js") %>" type="text/javascript"></script>
<% } %>
</asp:Content>
The following code is from my controller:
public ActionResult TestUsers()
{
string errormessage = string.Empty;
GetUsersModel ums = new GetUsersModel();
UserProvider up = new UserProvider();
try
{
if (!_provider.IsUserLoggedOn())
{
return RedirectToAction("LogOn", "Account");
}

if (ModelState.IsValid)
{
ViewData["rolelist"] = ums.Roles;
ViewData["isapprovedlist"] = ums.IsApproved;

ums.SearchResults = up.SearchUsers(ums.UserName, ums.SelectedRoleValue, ums.LastName, ums.FirstName, ums.MiddleName, ums.SelectedIsApprovedValue, out errormessage);
ums.SearchResults = ums.SearchResults.Take(20).ToList();
return View(ums);
}

}
catch (Exception e)
{
ModelState.AddModelError("", e.ToString());
}
ums.SearchResults = new List<UserModel>();
return View(ums);
}


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult TestUsers(PagingParams args, int? UserID)
{
if (!_provider.IsUserLoggedOn())
{
return RedirectToAction("LogOn", "Account");
}

UserProvider up = new UserProvider();
string errormessage = string.Empty;
if (UserID.HasValue)
{
RequestType currentRequest = (RequestType)Convert.ToInt32(args.RequestType);
if (currentRequest == RequestType.BeginEdit)
{

EditUserModel thisUser = up.GetEditUserByUserID(UserID.Value, out errormessage);
if (string.IsNullOrEmpty(errormessage))
{
return PartialView("EditUser", thisUser);
}
else
{
ModelState.AddModelError("", errormessage);
}
}
}

GetUsersModel ums = new GetUsersModel();
ums.SearchResults = up.SearchUsers(ums.UserName, ums.SelectedRoleValue, ums.LastName, ums.FirstName, ums.MiddleName, ums.SelectedIsApprovedValue, out errormessage);
IEnumerable data = ums.SearchResults.Take(20).ToList();
ActionResult result = data.GridJSONActions<UserModel>();
return result;
}

1 Reply

RR Ranjithkumar R G Syncfusion Team April 12, 2012 05:04 AM UTC

Hi Marc,

Thanks for using Syncfusion products.

We have analyzed your code snippet but we are unable to track the issue which you are facing. So we have created a simple sample which illustrates the behavior of ExternalForm edit mode.

Please refer to the below link to download the sample application.

http://www.syncfusion.com/downloads/Support/DirectTrac/General/Sample-661527899.zip

Could you please try the above sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.

Please let us know if you have any concerns.

Regards,
Ranjithkumar



Loader.
Live Chat Icon For mobile
Up arrow icon