harry code

harry code

  • NA
  • 124
  • 22.8k

Autocompleteextender not working

Dec 9 2018 11:40 PM
Hi,
 
I am working with Ajax Autocompleteextender.
 
It is not displaying the names .
 
Below is the sample code.
 
.cs
  1. [System.Web.Script.Services.ScriptMethod()]  
  2. [System.Web.Services.WebMethod]  
  3. public static List<string> Getfirstname(string prefixText)  
  4. {  
  5. string strFilter = string.Empty;  
  6. DataSet ds = new DataSet();  
  7. System.Data.DataTable dt = new System.Data.DataTable();  
  8. es_CustomersDAL ObjCustomersDAL = new es_CustomersDAL();  
  9. ds = ObjCustomersDAL.GetCustomers();  
  10. //ds = (DataSet)HttpContext.Current.Session["dsgroups"];  
  11. System.Data.DataView dv = ds.Tables[0].DefaultView;  
  12. strFilter += "ES_CustomerName LIKE '" + prefixText + "%'";  
  13. dv.RowFilter = strFilter;  
  14. dt = dv.ToTable();  
  15. List<string> GetCustomerName = new List<string>();  
  16. for (int i = 0; i < dv.Count; i++)  
  17. {  
  18. GetCustomerName.Add(dt.Rows[i]["ES_CustomerName"].ToString());  
  19. }  
  20. return GetCustomerName;  
  21. }  
.aspx
  1. <tr>  
  2. <td>  
  3. </td>  
  4. <td width="17%" >  
  5. First / Company Name  
  6. </td>  
  7. <td width="32%" >  
  8. <%--<asp:UpdatePanel ID="_udpCompanyName" runat="server">  
  9. <ContentTemplate>--%>  
  10. <asp:TextBox TabIndex="6" ID="txtfirstname" placeholder="Full Name of Comapany" runat="server" class="input ui-tooltip" MaxLength="110" title="Please enter slowely name."></asp:TextBox>  
  11. <asp:AutoCompleteExtender ID="auto1" runat="server" TargetControlID="txtfirstname" MinimumPrefixLength="1" EnableCaching="false" CompletionSetCount="1" CompletionInterval="100" ServiceMethod="Getfirstname"></asp:AutoCompleteExtender>  
  12. <%-- <asp:AutoCompleteExtender ID="AutoComptxtfirstname" runat="server" TargetControlID="txtfirstname" MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="100"  
  13. ServiceMethod="Getfirstname" >  
  14. </asp:AutoCompleteExtender>--%>  
  15. <span class="mandatoryfield">* </span><%--</ContentTemplate>  
  16. </asp:UpdatePanel>  
  17. --%>  
  18. </td>  
  19. <td width="13%" >  
  20. Last Name  
  21. </td>  
  22. <td width="38%" >  
  23. <asp:TextBox TabIndex="7" ID="txtlastname" runat="server" class="input" MaxLength="110"></asp:TextBox>  
  24. </td>  
  25. </tr>  

Answers (9)