我在 Asp.net ( C# ) 中编写了一个简单的 ajax 自动完成代码
这是代码
ASPX
<asp:TextBox ID="TextBox1" runat="server" Height="21px" Width="80px"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" MinimumPrefixLength="1" ServiceMethod="GetCompletionList" TargetControlID="TextBox1" UseContextKey="True"></asp:AutoCompleteExtender>
代码隐藏
string connString = ConfigurationManager.ConnectionStrings["Station"].ToString();
string selectString = "SELECT *from Station";
List<String> CustList = new List<string>(count);
using (SqlConnection sqlConn = new SqlConnection(connString))
{
sqlConn.Open();
using (SqlCommand sqlCmd = new SqlCommand(selectString, sqlConn))
{
SqlDataReader reader = sqlCmd.ExecuteReader();
while (reader.Read())
CustList.Add(reader["DBRT"].ToString());//DBRT is the Column name
}
}
return (CustList.ToArray());
当我执行并运行程序时,什么也没有发生。我不知道出了什么问题。请指导我。