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.
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: enumTypeSource 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
Hi Rahul,
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I set up a class which stores two GridModels and pass that to my view. Both grids set the AutoFormat property. When I run the page, I can see both grids without any errors.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 16.2.20162.2141 in Ignite UI 2016 Volume 2.
If the project does show the product feature working correctly, then more information will be needed to reproduce the issue in a sample that can be used for debugging. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing. This can be done by either making the sample that I provided more like your application or by isolating the behavior from your application by removing dependencies on any third parties or databases.
Please let me know if I can provide any further assistance.
Hi Mike,
Thank you for your quick response.
I am using the same code from this link https://ko.infragistics.com/community/forums/t/76844.aspx. (iggrid_model.zip). In my view I need to have multiple models, so I using a ViewModel Class to achieve this (https://www.codeproject.com/Articles/1108855/ways-to-Bind-Multiple-Models-on-a-View-in-MVC). The exception is caught only when I am using Viewmodel concept to pass multiple model objects into my view. But if I am passing just the Gridmodal object to view and rendering the using Razor (@Html.Infragistics().Grid(Model)) it works fine, the exception is not caught in browser. But still it can be seen if you debug using visual studio in model creation method as per the example in GetGridModel method. But as per my requirement I need to have multiple models in my view, but I cant fix the exception. I tried to set the gridModel.AutoFormat = GridAutoFormat.None; but this doesn't make any diffrence.
The code works fine and I am able to see the grid when I am passing just GridModel to view, But I need to have multiple Models in same view.
I am using ASP.NET MVC4, Visual Studio 2017, .net Version 4.5.2
Hello Rahul,
Thank you for contacting Infragistics!
The error you are getting is indicating that a property you are setting on the igGrid is expecting an Enum and is being setting to something else. What is the code you are using to setup the grid? Do you have a sample that demonstrates this issue.