CascadingDropDown控件读数据库不出东西
using System;
using System.Web;
using System.Collections;
using System.Configuration;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;
/**/
/// <summary>
/// Summary description for Northwind
/// </summary>
[WebService(Namespace = "http://tempuri.org/ ")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class Northwind : System.Web.Services.WebService
{
public Northwind()
{
}
[WebMethod]
public CascadingDropDownNameValue[] GetEmployees(string knownCategoryValues, string category)
{
string connectionString = ConfigurationManager.ConnectionStrings[ "Northwind "].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand( "SELECT * FROM Employees ");
command.Connection = connection;
connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
command.Connection.Close();
DataTable tbl = dataSet.Tables[0];
List <CascadingDropDownNameValue> values = new List <CascadingDropDownNameValue> ();
foreach (DataRow dr in tbl.Rows)
{
string sEmployee = (string)dr[ "FirstName "] + " " +dr[ "LastName "];
int iEmployee = (int)dr[ "EmployeeID "];
values.Add(new CascadingDropDownNameValue(sEmployee, iEmployee.ToString()));
}
return values.ToArray();
}