如何用ajax在textbox模糊查询之后绑定数据到dropdownlist
如何用ajax在textbox模糊查询之后绑定数据到dropdownlist,在网上找了一个例子,单独运行可以,假如到项目里面就不行,真是奇怪。。。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class xm_test : System.Web.UI.Page
{
     protected void Page_Load(object sender, System.EventArgs e)
     {
         Ajax.Utility.RegisterTypeForAjax(typeof(xm_test));
         if (!Page.IsPostBack)
         {
             this.TextBox1.Attributes.Add("onchange", "cityResult();");
             this.DropDownList1.Attributes.Add("onclick", "getData();");
         }
     }      
#region Web Form Designer generated code
     override protected void OnInit(EventArgs e)
     {
         //
         // CODEGEN: This call is required by the ASP.NET Web Form Designer.
         //
         InitializeComponent();
         base.OnInit(e);
     }
     /// <summary>
     /// Required method for Designer support - do not modify
     /// the contents of this method with the code editor.
     /// </summary>
     private void InitializeComponent()
     {
     }  
#endregion      
#region GetCityList
     [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
     public DataSet GetCityList(string id)
     {
         string sql = "select * from yx_user where user_id like '%" + id + "%'";
         return GetDataSet(sql);
     }      
#endregion      
#region GetDataSet
     public static DataSet GetDataSet(string sql)
     {
         string ConnectionString = ConfigurationManager.ConnectionStrings["partyConnectionString"].ToString();
         SqlDataAdapter sda = new SqlDataAdapter(sql, ConnectionString);
         DataSet ds = new DataSet();
         sda.Fill(ds);
         return ds;
     }      
#endregion
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="xm_test.aspx.cs" Inherits="xm_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <title>无标题页</title>
     <script language="javascript" type="text/javascript">                   
             function cityResult()  
             {  
                 var city=document.getElementById("TextBox1");
                 GetCityList(city.value,get_city_Result_CallBack);
             }              
             function get_city_Result_CallBack(response)
             {
                 if (response.value != null)
                 {                     
                     //debugger;
                     document.getElementById("DropDownList1").style.display="block";
                     document.getElementById(