public static string[] GetCOAList(string prefixText, int count, string contextKey) { string queryString = @"SELECT Top 20 AccountId,AccountName FROM COA WHERE AccountName LIKE '%" + prefixText.Trim().ToUpper() + "%' and AccountBranchId=" + CommonObjects.GetBranchId() + " and AccountId in (select AccountId from COALocation where Locationid=" + CommonObjects.GetLocationId() + ") "; List <string> items; string m_connectionString = ConfigurationManager.ConnectionStrings[ApplicationKeys.SqlConnectionString].ConnectionString; SqlConnection conn = new SqlConnection(); try { if (conn != null) { conn.Dispose(); conn = null; } conn = new SqlConnection(m_connectionString); conn.Open(); SqlCommand cmd = new SqlCommand(queryString, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapter.Fill(ds, 0, 30, "AccountId"); items = new List <string>(); string returnString = String.Empty; foreach (DataRow dr in ds.Tables[0].Rows) { items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr["AccountName"].ToString(), dr["AccountId"].ToString())); } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(items.ToArray()); }