Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai sir

i have a problem in using autocomplteextender control when i want to retrive data from database using entity concept.
please rectify my problem
Posted
Comments
Prerak Patel 14-Sep-11 5:04am    
Not clear.
Anuja Pawar Indore 20-Sep-11 3:06am    
Try to be more specific, what you are trying to ask is not clear.

You Can You This
http://stackoverflow.com/questions/2228229/autocomplete-extender-not-sorting-alphabetically
 
Share this answer
 
Go through my Code given bellow;
Add This in .aspx page

<asp:textbox id="txtSearchUserName" runat="server" width="400px" xmlns:asp="#unknown">
XML
<asp:AutoCompleteExtender ServiceMethod="GetProductList"
                        MinimumPrefixLength="1"
                        CompletionInterval="0" EnableCaching="false" CompletionSetCount="10"
                        TargetControlID="txtSearchUserName"
                        ID="autoCompleteExtender1" runat="server" FirstRowSelected ="true">
                    </asp:AutoCompleteExtender>


<asp:button id="btnSearchUserName" runat="server" xmlns:asp="#unknown">
OnClick="btnSearchUserName_Click" Text="Search" />

Put the code in .cs Page as given bellow,

C#
[System.Web.Script.Services.ScriptMethod()]
       [System.Web.Services.WebMethod]
       public static string[] GetProductList(string prefixText, int count)
       {
           using (var context = new YourDataBaseConnection())
           {
           // Get the Products From Data Source. Change this method to use Database
               var UserwebinarList = context.TableName.Where(c=>c.UserName!=null && c.IsActive==true) ;
               List<String> userList = new List<String>();
                 foreach (var item in UserwebinarList)
                   {
                       userList.Add(item.UserName);
                   }

           // Find All Matching Products
                 var list = from p in userList
                            where p.StartsWith(prefixText) || p.Contains(prefixText)
                                    select p;
             //Convert to Array as We need to return Array
               string[] prefixTextArray = list.ToArray<String>();
           //Return Selected Products
           return prefixTextArray;
           }
       }
 
Share this answer
 

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