0

I'm trying to display a telerik dropdownlist in a web forms page, with the following code

private void LoadCustomerControl()
   {
       try
       {
           IControlPanelPersistenceProvider persistenceProvider = new ControlPanelDatabaseProvider();
           List<CustomerDataGrid> customerCollection = persistenceProvider.ListCustomerGrid(false);
           if (customerCollection != null && customerCollection.Count != 0)
           {
               cboCustomer.DataSource = null;
               cboCustomer.DataSource = customerCollection;
               cboCustomer.DataBind();
           }
           else
           {
               //TODO add here message
               m_btnSubbmit.Visible = false;
               m_btnModifyCustomer.Visible = false;
           }
       }
       catch (Exception ex)
       {

           string excep = ex.ToString();
           //TODO add log here
       }
   }

Thing is that the list I'm getting is very big and then it raises this error in the browser

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

I have tried to add to the web config

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

I also tried to new up a javascriptserializer and set it's maxjsonlength to Int32.MaxLength, serialize the datasource and then deserialize back to the List of CustomerDataGrid but none work.

The call to that LoadCustomerControl is done via

if (Request.QueryString.Get("customerId") != null && Request.QueryString.Get("customerId").Length > 0)
           {
               //Is comming from CustomerPage, display the customer
               LoadCustomerControl();
               cboCustomer.SelectedValue = Request.QueryString.Get("customerId");
               cboCustomer.Text = GetCustomerName(int.Parse(Request.QueryString.Get("customerId").ToString()));
               m_btnModifyCustomer.Visible = true;
           }
}

Thanks,

mitomed
  • 2,006
  • 2
  • 29
  • 58

1 Answers1

0

Try adding following to the appsettings < add key="aspnet:MaxJsonDeserializerMembers" value="2147483644" />

Anil Goel
  • 261
  • 1
  • 8