Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i m using AutoCompleteExtender to display city list.I want to pass parameter using dropdown. Dropdown contains list of state name and their id. i want to pass id of state from that list of city populated in textbox.pleae help me to solve my problems.


XML
<asp:TextBox ID="txtAutoComplete" runat="server"></asp:TextBox>
        <ajax:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtAutoComplete"
             MinimumPrefixLength="1" EnableCaching="true" CompletionInterval="100"
            ServiceMethod="GetSuggessions"  UseContextKey="true"  ContextKey="<%# Eval(ddlState.SelectedValue) %>"
            CompletionSetCount="20" >
        </ajax:AutoCompleteExtender>



XML
[System.Web.Script.Services.ScriptMethod()]
     [System.Web.Services.WebMethod]

     public static List<string> GetSuggessions(string prefixText, int count, long contextKey)
     {
         // prefixText – text entered in the textbox
         //fill list with suggestive words that will be populated in the list below the textbox


        // List<string> res = new List<string>() { "a", "a1", "a2", "a3", "b", "b1", "b2", "b3" };

          List<string> res = MasterDTO.GetCities(contextKey).Select(s => s.CityName.ToLower()).ToList();
         List<string> suggestions = res
       .Where(a => a.StartsWith(prefixText.ToLower()))
       .Take(count)
       .ToList();
         // contextKey can be used to set further filter
         return suggestions;
     }
Posted

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