Hi dude i am facing a little problem.When i first time implemented auto complete suggestion it work properly but now after one month i use many other field to extend them as auto suggestion all of them are working but give suggestion in a single line.Please any one give me a solution.Thanks in advance.

<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>

 <ajaxToolkit:AutoCompleteExtender ID="autocomplete" runat="server" TargetControlID="txtsupgname"
                    ServicePath="autoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="2" 
                    CompletionInterval="100" EnableCaching="true" CompletionSetCount="20"      
                    ShowOnlyCurrentWordInCompletionListItem="true" >
                    </ajaxToolkit:AutoCompleteExtender>


<asp:TextBox ID="txtsupgname"  runat="server" Width="185px" TabIndex="1" 
                            ForeColor="Black" MaxLength="40"></asp:TextBox>

public class autoComplete : System.Web.Services.WebService 
{

        [WebMethod]
    public string[] GetCompletionList(string prefixText, int count)
    {
        using (SqlConnection cn = ConnectionManager.GetConnection())
        {
            using (SqlCommand cmd = new SqlCommand("SELECT * FROM SupplierGroupSetup WHERE supg_name LIKE '%" + prefixText + "%'", cn))
            {
                cmd.CommandType = CommandType.Text;
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                try
                {
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);

                }

                catch { }

                finally
                {
                    cn.Close();
                }
                dt = ds.Tables[0];
                List<string> txtItems = new List<string>();
                string dbValues;

                foreach (DataRow row in dt.Rows)
                {
                    dbValues = row["supg_name"].ToString();
                    dbValues = dbValues.ToLower();
                    txtItems.Add(dbValues);
                }
                return txtItems.ToArray();
            }
        }

    }
}
Member Avatar for stbuchok

Can you provide a screenshot so that we can better understand your problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.