Click here to Skip to main content
15,610,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use jquery auto complete in
i have problem when the array of autocomplete is more then 2000
but when it less than 2000 i doesn't have any problem
i use <%=sorce%> in the array of script and Get Values from database from behinde code
but when i it be larger the auto complete doesn't work
        <pre lang="Javascript">
$(function () {
            var availableTags = [
                source: availableTags

and this is my behind code
SqlCommand cmd = new SqlCommand("Select الاسم From حلب", conAleppoM);
        if (conAleppoM.State.ToString() == "Closed") { conAleppoM.Open(); }
        SqlDataReader dr = cmd.ExecuteReader();
        int i = 0; 
        List<string> lst = new List<string>();
        while (dr.Read())
            if (dr["الاسم"].ToString() != "" && dr["الاسم"].ToString() != "مجهول الهوية" && dr["الاسم"].ToString() != "مجهولة الهوية" && dr["الاسم"].ToString() != "مجهول الاسم" && dr["الاسم"].ToString() != "مجهول الكنية")
            //if (i == 1000) { break; }
        bool bl = false;
        foreach (string str in lst)
            if (!bl) { sours = "\"" + str + "\",\n"; bl = true; }
                if (!sours.Contains(str))
                    sours = sours + "\"" + str + "\",\n";
Updated 4-May-13 1:17am

use this in your web.config may be solved your problem

        <jsonserialization maxjsonlength="2147483644" />
Share this answer
Mallok96 4-May-13 10:49am    
it doesn't work
i have 10000 rows in my database when i break on 2000 it work
There are several thing I have noticed in your code:
- First of all, autocomplete is not for returning too many rows, since that has makes no sense. It is meant to be used by people, so a maximum of 15-20 elements is enough. While the user is typing, the list will refine content.
- You are currently filling up the autocomplete list in the html code (from code behind, but that's the same in this situation), so you have every element in the html which makes it static in some form. You should use the dynamic version, with an ajax callback to a ScriptService. Check this:[^]
- Use the text portion entered by the user (the parameter you get in the scriptservice method) to filter the returned list. All the conditions you added from code to get records with proper values - you can put in the select statement. You should put them there. And you should put a limitation to the fetched records by adding a TOP clause[^].
The query would look like this:
SELECT TOP 20 fieldname FROM table WHERE fieldname IS NOT NULL AND fieldname NOT IN ('value1','value2','value3','value4') AND الاسم LIKE @filter

(And do't forget to add wildcards to the @filter when passing the parameter value)
Share this answer
it doesn't work
i have 10000 rows in my database when i break on 2000 it work
Share this answer
Why are you adding one answer as you have already commented inside the answer box ?
Please delete this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900