Hi Waghmare,
You need to do bit workaround for what you are trying to achieve and you cant get exactly with Ajax AutoCompleteExtender because we get bound to the limitations of Ajax AutoCompleteExtender.
I have taken a reference from below article.
I have created a sample which full fill your requirement you need to modify the code according to your need.
HTML
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<asp:TextBox ID="txtEmployeeSearch" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="SearchEmployees" MinimumPrefixLength="1"
CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtEmployeeSearch"
OnClientPopulated="Employees_Populated" ID="AutoCompleteExtender1" runat="server"
FirstRowSelected="false">
</cc1:AutoCompleteExtender>
</div>
<div>
<script type="text/javascript">
function Employees_Populated(sender, e) {
var employees = sender.get_completionList().childNodes;
var div = "<table>";
div += "<tr><th>EmployeeId</th><th>FirstName</th><th>LastName</th><th>City</th><th>Country</th></tr>";
for (var i = 0; i < employees.length; i++) {
div += "<tr><td>" + employees[i].innerHTML.split('-')[0] + "</td><td>" + employees[i].innerHTML.split('-')[1] + "</td><td>" + employees[i].innerHTML.split('-')[2] + "</td><td>" + employees[i].innerHTML.split('-')[3] + "</td><td>" + employees[i].innerHTML.split('-')[4] + "</td></tr>";
}
div += "</table>";
sender._completionListElement.innerHTML = div;
}
</script>
</div>
C#
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchEmployees(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["constr"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT EmployeeId, FirstName, LastName,City,Country FROM Employees WHERE FirstName like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> employees = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
employees.Add(AjaxControlToolkit.AutoCompleteExtender
.CreateAutoCompleteItem(string.Format("{0}-{1}-{2}-{3}-{4}",
sdr["EmployeeId"].ToString(), sdr["FirstName"], sdr["LastName"], sdr["City"], sdr["Country"]),
sdr["EmployeeId"].ToString()));
}
}
conn.Close();
return employees;
}
}
}
VB.Net
<System.Web.Script.Services.ScriptMethod(), _
System.Web.Services.WebMethod()> _
Public Shared Function SearchEmployees(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim conn As SqlConnection = New SqlConnection
conn.ConnectionString = ConfigurationManager _
.ConnectionStrings("constr").ConnectionString
Dim cmd As SqlCommand = New SqlCommand
cmd.CommandText = "select EmployeeId, FirstName, LastName,City,Country from " & _
" Employees where FirstName like @SearchText + '%'"
cmd.Parameters.AddWithValue("@SearchText", prefixText)
cmd.Connection = conn
conn.Open()
Dim employees As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
employees.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(String.Format("{0}-{1}-{2}-{3}-{4}", sdr("EmployeeId").ToString(), sdr("FirstName"), sdr("LastName"), sdr("City"), sdr("Country")), sdr("EmployeeId").ToString()))
End While
conn.Close()
Return employees
End Function
ScreenShot