This is a migrated thread and some comments may be shown as answers.

Error during serialization or deserialization using the JSON JavaScriptSerializer - With Self Referencing RadGrid

3 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
venkatraman
Top achievements
Rank 1
venkatraman asked on 15 Oct 2008, 12:00 PM

I am trying to use the self-referencing hierarchy functionality of the grid but not working properly when we have huge data.

We are getting the error as follows,

 "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."

When i googgled,i got the following code snippet has to be added in  the web.config to increase the maxJsonLength property:

 <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="500000">
        </jsonSerialization>
      </webServices>
    </scripting>
  </system.web.extensions>

We also tried to increase the maxJsonLength value. But still  getting the same error.

My code:

.aspx page:

<telerik:RadGrid ID="RadGrid1" runat="server" Skin="" Width="97%" GridLines="None"
        ShowHeader="False">
        <MasterTableView HierarchyDefaultExpanded="True" HierarchyLoadMode="Client" DataKeyNames="ID,ParentScheduleID"
            Width="100%" AutoGenerateColumns="False">
            <SelfHierarchySettings ParentKeyName="ParentScheduleID" KeyName="ID" MaximumDepth="2"  />
            <Columns>
                <telerik:GridBoundColumn DataField="ScheduleName" HeaderText="ScheduleName" UniqueName="ScheduleName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

.aspx.cs:(code behind)

  protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {        

            BindGrid();
        }
    }

    public void BindGrid()
    {
        DBLayer objDbLayer= new DBLayer();    

        DataSet dsSchedules = objDbLayer.GetScheduleData(ProjectId);

        if (dsSchedules.Tables.Count > 0)
        {           
            RadGrid1.DataSource = dsSchedules.Tables[0];

            RadGrid1.DataBind();
        }


    }

kindly help to resolve this error.

Thanks & Regards,

Venkatraman Gururaj.

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 17 Oct 2008, 01:29 PM
Hello venkatraman,

Can you please provide little more details about your implementation? To how many records you are binding? You also may consider using HierarchyLoadMode=ServerOnDemand.

Regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
venkatraman
Top achievements
Rank 1
answered on 03 Nov 2008, 01:13 PM
Hi Rosen,

     Thanks for you reply and very sorry for the late reply.

   Actually i have been working with Schedule kind of concept, where i can have List of schedule and child schedules. A child schedule can have more and more childs ...like a Treeview.

  currently i have around 550 records in a table. which also has self-referenced column called ParentScheduleId

As i work around this ,

HierarchyLoadMode=ServerOnDemand (with paging), if i click on (+ sign) to load the child rows, the child rows are not getting populated, and page is getting post back and  not displaying any rows. But grid shows simply empty.

HierarchyLoadMode=Client, is also working only if i have less then 20 fields, more than 20 fields returns the same error..........

"Error during serialization or deserialization using the JSON ...."

Waiting for your response.......

Thanks & Regards,

Venkatraman Gururaj.
 
0
Sebastian
Telerik team
answered on 04 Nov 2008, 09:16 AM
Hi venkatraman,

It seems that you are using simple binding with DataBind() calls to populate the grid. I suggest you use advanced binding with NeedDataSource handling as shown in the self-referencing hierarchy demo:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Hierarchy/SelfReferencing/DefaultCS.aspx

and verify that the conventions for self-referencing settings are fulfilled with your configuration:

http://www.telerik.com/help/aspnet-ajax/grdselfreferencinghierarchy.html

Also make sure that you are using the latest version 2008.2.1001 of RadControls for ASP.NET AJAX.

Best,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
venkatraman
Top achievements
Rank 1
Answers by
Rosen
Telerik team
venkatraman
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or