using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
namespace Warehouse
{
public partial class DropDownHelper2 : System.Web.UI.Page, IHttpHandler//, IRequiresSessionState
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.Write("cao l nengdaozhelema");
string a = Request["type1"];
Response.Write(a);
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string sql = "select WS_Name,WS_Id from W_Warehouse,W_Sort where WS_Warehouse=WW_Id and WW_Id='" +a+ "'";
SqlDataAdapter myda = new SqlDataAdapter(sql, mycon);
DataSet myset = new DataSet(); myda.Fill(myset);
DataTable mytable = myset.Tables[0];
int n = mytable.Rows.Count;
String str = "";
for (int i = 0; i < n; i++)
{
string Sort = mytable.Rows[i]["WS_Name"].ToString();
string SortId = mytable.Rows[i]["WS_Id"].ToString();
if (i >= 1)
str += "|";
str += "\"" + Sort + ":" + SortId + "\"";
}
Response.Write(str);
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
namespace Warehouse
{
public partial class DropDownHelper2 : System.Web.UI.Page, IHttpHandler//, IRequiresSessionState
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.Write("cao l nengdaozhelema");
string a = Request["type1"];
Response.Write(a);
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string sql = "select WS_Name,WS_Id from W_Warehouse,W_Sort where WS_Warehouse=WW_Id and WW_Id='" +a+ "'";
SqlDataAdapter myda = new SqlDataAdapter(sql, mycon);
DataSet myset = new DataSet(); myda.Fill(myset);
DataTable mytable = myset.Tables[0];
int n = mytable.Rows.Count;
String str = "";
for (int i = 0; i < n; i++)
{
string Sort = mytable.Rows[i]["WS_Name"].ToString();
string SortId = mytable.Rows[i]["WS_Id"].ToString();
if (i >= 1)
str += "|";
str += "\"" + Sort + ":" + SortId + "\"";
}
Response.Write(str);
}
}
}
此代码也是后台代码,前台默认即可!到此使用ajax实现三级下拉列表级联已完成,代码中可能涉及到数据库操作,做相应改变即可!