我试过这段代码
**java script to add html controls in autocomplete**
<script type = "text/javascript">
function Employees_Populated(sender, e) {
var employees = sender.get_completionList().childNodes;
for (var i = 0; i < employees.length; i++) {
var div = document.createElement("DIV");
div = "<table border='5px' width='400px'><tr><td><img style = 'height:50px;width:50px' src = 'photos/"
+ employees[i]._value + ".jpg' /></td><td><button name='BtnG' id='gbqfb'></asp:Button></td></tr></Table><br/> ";
employees[i].appendChild(div);
}
}
function OnEmployeeSelected(source, eventArgs) {
var idx = source._selectIndex;
var employees = source.get_completionList().childNodes;
var value = employees[idx]._value;
var text = employees[idx].firstChild.nodeValue;
source.get_element().value = text;
}
</script>
用于在自动填充中绑定数据库的服务器端代码
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select Id, Name, City from" +
" webInfo where Name like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = cn;
cn.Open();
List<string> employees = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
employees.Add(AjaxControlToolkit.AutoCompleteExtender
.CreateAutoCompleteItem(string.Format("{0} {1} {0}",sdr["Name"], sdr["City"],sdr["ID"]),
sdr["Id"].ToString()));
}
}
cn.Close();
return employees;
}
输出
我想显示网格视图或转发器内部的按钮,但如何做到这一点,我不知道
答案 0 :(得分:0)
这里不需要使用自动完成功能,只需绑定转发器中的所有数据并根据文本字段字符对其进行排序
你必须在转发器的tr中找到输入字符, 如果发现可见其他所有tr隐藏 p>
使用Jquery