Too many items for Javascript to handle in a Callback

2 posts, 0 answers
  1. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 23 Jun 2010 Link to this post

    I'm using the following demo to load Combo items from a DB which I don't have linked to an Entity model (so old command query).

     
        [WebMethod(CacheDuration = 0)] 
        public RadComboBoxItemData[] LoadMedportalUsers(RadComboBoxContext context) { 
            IDictionary<stringobject> contextDictionary = (IDictionary<stringobject>)context; 
            string filterString = ((string)contextDictionary["FilterString"]).ToLower(); 
     
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["myDB"].ConnectionString); 
     
             
            SqlCommand selectCommand = new SqlCommand(@" SELECT UserID, UserName FROM Aspnet_Users
                                                         WHERE LOWER(UserName) LIKE '%" + filterString + "%'", connection); 
     
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); 
            DataTable users = new DataTable(); 
            adapter.Fill(users); 
     
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(users.Rows.Count); 
     
            foreach (DataRow row in users.Rows) { 
                RadComboBoxItemData itemData = new RadComboBoxItemData(); 
                itemData.Text = row["UserName"].ToString(); 
                itemData.Value = row["UserID"].ToString(); 
                result.Add(itemData); 
            } 
            return result.ToArray(); 
        } 

    We have about 3000 users in the AspNet_Users table...so this throws:
    Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

    Is there perhaps a way to tweak to allow the dynamic loading?

    Any way around that?


  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 24 Jun 2010 Link to this post

    Hello Steve,

    You can increase the maxJsonLength property value in your web.config as described here.

    Kind regards,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top