Quote:<asp:textbox id="username" textmode="SingleLine" runat="server" xmlns:asp="#unknown"> ToolTip="Enter username" AutoCompleteType="DisplayName" Height="22px"> <ajax:autocompleteextender id="AutoCompleteExtender1" runat="server" targetcontrolid="username" xmlns:ajax="#unknown"> MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" ServiceMethod="GetCountries" >
Quote: [System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod] public static List<string> GetCountries(string prefixText) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["schoolconn"].ToString()); con.Open(); SqlCommand cmd = new SqlCommand("select * from login_details where username like @Name+'%'", con); cmd.Parameters.AddWithValue("@Name", prefixText); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); List<string> CountryNames = new List<string>(); for (int i = 0; i < dt.Rows.Count; i++) { CountryNames.Add(dt.Rows[i][2].ToString()); } return CountryNames; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)