Getting a value from drop down to Ajax auto complete event

misshollywood

New Member
I have country list in a dropdown list and I want to bind the table name with the autocomplete event of the text box as below:\[code\][System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] sql(string prefixText, int count, string contextKey) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conx"].ConnectionString); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter("SELECT [city_name]FROM [pinfo].[dbo].["+ddl_country.selecteditem.text+"]", con); ad.Fill(ds, "data"); con.Close(); string[] main= new string[0]; for (int i = 0; i < ds.Tables[0].Rows.Count-1; i++) { if (ds.Tables[0].Rows.ItemArray[0].ToString().ToLower().StartsWith(prefixText.ToLower())) { Array.Resize(ref main,main.Length + 1); main[main.Length - 1] = ds.Tables[0].Rows.ItemArray[0].ToString(); if (main.Length == 20) break; } } Array.Sort(main); return main; //return default(string[]); }\[/code\]especially this line \[code\] SqlDataAdapter ad = new SqlDataAdapter("SELECT [city_name]FROM [pinfo].[dbo].["+ddl_country.selecteditem.text+"]", con);\[/code\]I want the dropdown value in the above string.
 
Back
Top