我正在使用 AjaxAutoComplete Extender 在旅途中填充城市的值。但我有一个问题。
一切正常,但是当我按向下箭头浏览结果时,它什么也不做,它永远不会从第一个结果移动..我在这里做错了什么..
并且值也填充在网页顶部,而不是文本框下方..之前它工作正常,但现在不行..
ASP.NET
<asp:TextBox ID="fromlocation" runat="server" CssClass="ddl"></asp:TextBox>
<autofill:AutoCompleteExtender
ServiceMethod="GetCompletionList"
ID="fromlocation_AutoCompleteExtender"
runat="server"
DelimiterCharacters=""
Enabled="True"
ServicePath=""
TargetControlID="fromlocation"
UseContextKey="True"
MinimumPrefixLength="2"
CompletionInterval="10"
EnableCaching="true"
CompletionSetCount="3"
CompletionListItemCssClass="autocomplete_listItem">
</autofill:AutoCompleteExtender>
C#
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connstring"].ToString());
SqlCommand cmd = new SqlCommand("SELECT coalesce(Code + ', ', '') + City as codes FROM CCode WHERE City LIKE '" + prefixText + "%'", conn);
SqlDataReader oReader;
conn.Open();
List<string> CompletionSet = new List<string>();
oReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (oReader.Read())
CompletionSet.Add(oReader["codes"].ToString());
return CompletionSet.ToArray();
}