Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Getting System.ArgumentException when grid is created dynamically from ASP.NET MVC Controller
posted

Hi,

I am using Ignite UI grid to populate my data from ASP.NET MVC. I am following "">www.infragistics.com/.../76844.aspx" to dynamically create the grid from Controller. I tried debgging the solution, there is a method in the example "GetGridModal" which will dynamically create the grid and configure it. Just before returning the gridmodal in the method, when I am checking the properties of grid modal there is a exception in AutoFormat proerty. But the method will be excecued successfully. On returning to View with the GridModal as per example, it throws an Exception. In the example they are passing GridModal object. Instead of that  am creating a new class which wll be like a master model, wich can contain othr models too. I specifically getting the exception when I using this approch. If I go with the GridModal approach I am not getting the excetion in broser, i.e processing is not stopped and the grid is rendered successfully. But still i can see the AutoFormat exception in GetGridModal method. I have pasted the exception below. Can you please suggest a solution for this as soon as possible. 

Server Error in '/' Application.


Type provided must be an Enum.
Parameter name: enumType

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.ArgumentException: Type provided must be an Enum.
Parameter name: enumType

Source Error: 

Line 79:     <div>
Line 80: 
Line 81: @(Html.Infragistics().Grid<MyIgniteUITestPOC.ViewModel.EmployeeViewModel>(Model.gridmodal)) Line 82: 
Line 83:         <div class="gridbtn" style="padding:5px">


Source File: c:\Users\SRahul\Documents\New Test\MyIgniteUITestPOC\MyIgniteUITestPOC\Views\Employee\Employee.cshtml    Line: 81 

Stack Trace: 

[ArgumentException: Type provided must be an Enum.
Parameter name: enumType]
   System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult) +12864199
   System.Enum.Parse(Type enumType, String value, Boolean ignoreCase) +78
   Infragistics.Web.Mvc.GridModel.get_AutoFormat() +51

[TargetInvocationException: Property accessor 'AutoFormat' on object 'Infragistics.Web.Mvc.GridModel' threw the following exception:'Type provided must be an Enum.
Parameter name: enumType']
   System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +378
   System.Web.Mvc.HtmlHelper.AnonymousObjectToHtmlAttributes(Object htmlAttributes) +177
   Infragistics.Web.Mvc.InfragisticsSuite`1.Grid(Object htmlAttributes) +66
   ASP._Page_Views_Employee_Employee_cshtml.Execute() in c:\Users\SRahul\Documents\New Test\MyIgniteUITestPOC\MyIgniteUITestPOC\Views\Employee\Employee.cshtml:81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +236
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +245
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +22
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +176
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +75
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129