Subin Thomas

Subin Thomas

  • NA
  • 4.9k
  • 127.2k

autocomplete extender how does it work

Feb 24 2019 11:39 PM
i have have taken project name and project code in a autocomplete textbox the code is given below when i type name it comes with respective code , i want to know how what is assigned in that textbox name or code because i want to give further function for code only
 
  1. [System.Web.Script.Services.ScriptMethod()]  
  2.         [System.Web.Services.WebMethod]  
  3.   
  4.         public static List<string> GetSearch(string prefixText)  
  5.         {  
  6.   
  7.             DataTable dt = new DataTable();  
  8.             SqlConnection con = new SqlConnection(con_Vas);  
  9.             SqlCommand cmd = new SqlCommand("SELECT [Employee Name]+';     '+[Employee Code] as Name FROM [HRPLK].[dbo].[View_EmployeeBasicInformation] where [Employee Name] like '%'+ @EmpName +'%' ");        
  10.             cmd.Parameters.AddWithValue("@EmpName", prefixText);  
  11.             cmd.Connection = con;  
  12.             con.Open();  
  13.             List<string> employees = new List<string>();  
  14.             using (SqlDataReader sdr = cmd.ExecuteReader())  
  15.             {  
  16.                 while (sdr.Read())  
  17.                 {  
  18.                     employees.Add(sdr["Employee Code"].ToString());  
  19.   
  20.                 }  
  21.             }  
  22.   
  23.             
  24.             con.Close();  
  25.   
  26.             return employees;  
  27.   
  28.   
  29.         } 
 

Answers (11)