[WebMethod] public List<string> GetNames(string prefixText) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString()); con.Open(); SqlCommand cmd = new SqlCommand("select * from familytwo where Name like @Name+'%'", con); cmd.Parameters.AddWithValue("@Name", prefixText); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); List<string> Names = new List<string>(); for (int i = 0; i < dt.Rows.Count; i++) { Names.Add(dt.Rows[i][1].ToString()); } return Names; }
<asp:TextBox ID="TextBox2" runat="server" Width="244px"> <ajax:AutoCompleteExtender ID="AutoCompleteExtender" runat="server" TargetControlID="TextBox2" ServiceMethod="GetNames" ServicePath="~/autocompleteasmx.asmx" MinimumPrefixLength="1" EnableCaching="true" CompletionInterval="1000" CompletionSetCount="1">
DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)