如何创建数据驱动的自动完成下拉TextBox?

时间:2015-11-18 10:00:15

标签: c# asp.net

我在教程的帮助下制作了这段代码,现在的问题是我想要数据驱动的自动完成TextBox使用jQuery for ASP.NET网站但是当我运行这段代码时它没有任何错误,但它无法显示下拉列表和无法显示OCRD表中的数据:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;
using System.Data.Sql;
using System.Web.Services;

namespace tutorialPoints
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        [WebMethod]
        public static List<string> GetCardNames(string empName)
        {
            List<string> Emp = new List<string>();
            string query = string.Format("SELECT CardName FROM OCRD WHERE CardName LIKE '%{0}%'", CardName);
            using (SqlConnection con = new SqlConnection("Data Source=1.2.3.4;Initial Catalog=TestData;Persist Security Info=True;User ID=abc;Password=abcd");
            {
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Emp.Add(reader.GetString(0));
                    }
                }
            }
            return Emp;
        }

        public static SqlConnection con { get; set; }

        public static string CardName { get; set; }
    }
}

I want output like thisI want output like this

0 个答案:

没有答案