I am using autocompleteextender in my asp.net website. It is working fine. I want additional functionality when user types it shows suggestion like below
suppose I type P in textbox Result - PNQ , PAR, PBC etc
Here evry keyword has fullform in second column so I want data to display like this
PNQ (Pune Airport)
When this value get selected by user then should only select PNQ in textbox not entire value i.e PNQ (Pune Airport). This I want becuase users should get clear what they are selecting. Can anyone help me in this.
<asp:AutoCompleteExtender ServiceMethod="SearchClientCode"
ServicePath="~/myadmin/shipments-profile.aspx" MinimumPrefixLength="1"
OnClientShown="resetPosition" CompletionInterval="100" EnableCaching="false"
CompletionSetCount="10" TargetControlID="clientCode" ID="clientCodeExtender"
runat="server" FirstRowSelected="false" CompletionListCssClass="completionList"
CompletionListItemCssClass="listItem"
CompletionListHighlightedItemCssClass="itemHighlighted"></asp:AutoCompleteExtender>
[System.Web.Script.Services.ScriptMethod(), System.Web.Services.WebMethod()]
public static List<string> SearchClientCode(string prefixText, int count)
{
MySqlConnection conn = new MySqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings("conio").ConnectionString;
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "SELECT clientID, clientName FROM clientsDetails where (clientID like @SearchText)";
cmd.Parameters.AddWithValue("@SearchText", prefixText + "%");
cmd.Connection = conn;
conn.Open();
List<string> customers = new List<string>();
MySqlDataReader sdr = cmd.ExecuteReader;
while (sdr.Read) {
customers.Add(sdr("clientID").ToString);
}
conn.Close();
return customers;
}