【发布时间】:2016-04-07 16:58:42
【问题描述】:
我正在尝试使用以下代码在 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;
}
}
谢谢,
【问题讨论】: