<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> <Services> <asp:ServiceReference Path="~/AutoComplete.asmx" /> </Services> </asp:ScriptManager> <div> <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox> <cc1:AutoCompleteExtender ID="txtCountry_AutoCompleteExtender" runat="server" ServicePath="AutoComplete.asmx" ServiceMethod="GetCountriesList" MinimumPrefixLength="1" EnableCaching="true" Enabled="true" TargetControlID="txtCountry"> </cc1:AutoCompleteExtender> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" Enabled="True" TargetControlID="TextBox1" PopupButtonID="TextBox1"> </cc1:CalendarExtender> </div> </form> </body> </html>
public string[] GetCountriesList(string prefixText) { DataSet dtst = new DataSet(); SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["ConString"]); string strSql = "SELECT Fullname FROM owner.empmaster WHERE Fullname LIKE '" + prefixText + "%' and owner.empmaster.active=0 and owner.empmaster.status=0 "; SqlCommand sqlComd = new SqlCommand(strSql, sqlCon); sqlCon.Open(); SqlDataAdapter sqlAdpt = new SqlDataAdapter(); sqlAdpt.SelectCommand = sqlComd; sqlAdpt.Fill(dtst); string[] cntName = new string[dtst.Tables[0].Rows.Count]; int i = 0; try { foreach (DataRow rdr in dtst.Tables[0].Rows) { cntName.SetValue(rdr["Fullname"].ToString(), i); i++; } } catch { } finally { sqlCon.Close(); } return cntName; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)