我正在尝试在Web表单页面中显示telerik下拉列表,其中包含以下代码
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
}
}
事实是,我得到的列表非常大,然后在浏览器中引发此错误
异常消息:序列化或反序列化期间出错 JSON JavaScriptSerializer。字符串的长度超过了 在maxJsonLength属性上设置的值。
我试图添加到网络配置
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644 "/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
我还尝试新建一个javascriptserializer,并将其maxjsonlength设置为Int32.MaxLength,序列化数据源,然后反序列化回CustomerDataGrid列表但不起作用。
对LoadCustomerControl的调用是通过
完成的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;
}
}
谢谢,
答案 0 :(得分:0)
尝试在appsettings中添加以下内容 &LT; add key =“aspnet:MaxJsonDeserializerMembers”value =“2147483644”/&gt;