AutoCompleteExtender控件实现自动补全功能
我想用AutoCompleteExtender控件三层中实现自动补全功能,在页面上面已经拖了ScriptManager和AutoCompleteExtender,并设置好了AutoCompleteExtender的几个必要属性
web code:----------------------------------------------------------------
[WebMethod(Description="查询自动补全")]
public string[] GetHotSearchByKeywords(string prefixText,int count)
{
//根据关键字,返回查询结果
return userbll.GetHotSearchKeywords(prefixText,count);
}
DAL code:---------------------------------------------------------------
/// <summary>
/// 实现关键字查询用户名
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
public string[] GetHotSearchKeywords(string prefixText, int count)
{
List<UserInfo> users = new List<UserInfo>();
string sqlHot = "select top" + count + "* username from userinfo where username like '" + prefixText + "%'";
DataTable table = DBHelper.QueryData(sqlHot).Tables[0];
List<string> strs = new List<string>();
foreach (DataRow row in table.Rows)
{
strs.Add(row["UserName"].ToString());
}
return strs.ToArray();
}
BLL coed:----------------------------------------------------------------
// <summary>
/// 根据关键字查询自动完成功能
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
public string[] GetHotSearchKeywords(string prefixText, int count)
{
return userinfodal.GetHotSearchKeywords(prefixText,count);
}
-----------------------------------------------------------------
文本框也有AutoCompleteExtender1属性了,其中的方法名和路径都改好了,但是运行却没有效果,是怎么回事啊?
各位懂的帮忙分析下咯 谢谢
------解决方案--------------------
string sqlHot = "select top" + count + "* username from userinfo where username like '" + prefixText + "%'";
这个确定没有问题吗???