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 on Grid


Hi,

The references of the syncfusion libraries in the layout page makes that the functions in my controller page are called several times, and it provoques that many of my temporary variables loose their values.

Is there a way to avoid this behavior?

I tried to comment this references in the layout page, and put them in my view page as follows

@section scripts{    
    <script src="~/Scripts/ej/web/ej.web.all.min.js"></script>
    @Scripts.Render("~/Scripts/jquery.easing.1.3.js")
    @Scripts.Render("~/Scripts/jsrender.min.js")
    <link rel='nofollow' href="~/Content/ej/web/bootstrap-theme/ej.web.all.min.css" rel="stylesheet" />
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
    <script type="text/javascript">
........

</script>
But I get the following error

Type 'System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for serialization/deserialization of a dictionary, keys must be strings or objects.

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 'System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for serialization/deserialization of a dictionary, keys must be strings or objects.

Source Error: 

 

Line 104:</div>

Line 105:            @Html.EJ().ScriptManager()

Line 106:            @(Html.EJ().Grid<DatosCapacitacion>("GridCapacitaciones")

Line 107:            .Datasource((IEnumerable<DatosCapacitacion>)ViewBag.Capacitaciones)

Line 108:            .Locale("es-MX")


Source File: C:\Users\laura.jordan\Documents\TRABAJO\Proyectos\RRHH\HumanResoursesJAR\HumanResourcesJAR\Views\CapitalHumano\Capacitaciones.cshtml    Line: 106 



Thanks in advance

3 Replies

SA Saravanan Arunachalam Syncfusion Team January 26, 2017 10:51 AM UTC

HI Dayne, 
Thanks for contacting Syncfusion’s support. 
We suspect that you have tried to convert the Dictionary object with integer key and object value as JSON by using JavaScriptSerializer which is the cause of the issue. So, please refer to the below stackoverflow link to resolve the issue. 
Regards, 
Saravanan A. 



DA Dayne January 26, 2017 03:55 PM UTC

Ok, I fix the error, but the main issue still persist.

In my layout page, I have this code, among other things:
.......
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/waitMe/waitMe.js" type="text/javascript"></script>
    @Scripts.Render("~/Scripts/jquery.easing.1.3.js")
    @Scripts.Render("~/Scripts/jsrender.min.js")
    <script src="~/Scripts/ej/web/ej.web.all.min.js"></script>
    @RenderSection("scripts", required: false)
    @Html.EJ().ScriptManager()
......

And I have a view wich is a formulary page, in the controller functions (GET and POST) of that view I have many temporary variables, so, in debug mode I realized that when the user request a POST action, the controller function is called several times, making that the temporary variables loose their value.

Sorry If my English is not good enough, I could try to explan it in Spanish..


VA Venkatesh Ayothi Raman Syncfusion Team January 27, 2017 11:13 AM UTC

Hi Dyane, 
Thanks for the update. 
The reported issue is reproduced in two ways. First the JavaScriptSerializer don’t deserialize the dictornary object and second, if you have any complex types and dates. So, we suggest you to use Newtonsoft.json for deserialize your Dictionary objects or complex types. Please refer to the online forum for your reference, 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon