[System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod()] public List<string> GetCompletionList(string prefixText) { SqlParameter[] p = new SqlParameter[1]; p[0] = new SqlParameter("@data", prefixText); DataTable dt = dl.GetDataWithParameters("Sp_GetPriceRef_ddl1", p); List<string> items = new List<string>(); foreach(DataRow dr in dt.Rows) { string strName = dr["OldRef"].ToString(); items.Add(strName); } return items; }
<asp:TextBox ID="txtpRef" Width="100px" runat="server" ></asp:TextBox> <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20" TargetControlID="txtpRef" MinimumPrefixLength="1" ServiceMethod="GetCompletionList" ServicePath="WebService.asmx" ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";, :"> </ajaxToolkit:AutoCompleteExtender>
Add Script Manager in your page. <asp:ScriptManager runat="server" />
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)