大虾救命! dropdownlist三级联动实现不了?(VS2005+sql)
html
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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">...
//绑定City
function BindToCity(ProvinceID,DDL_City_ID)
{
var DataSet_City = _Default.BindToCity(ProvinceID).value;//注意加Value
var DDL_City = document.getElementById(DDL_City_ID);
DDL_City.length = 0;//清除已有选项
var Length = DataSet_City.Tables[0].Rows.length;
if(Length!="0")
{
for(var i=0;i<Length;i++)
{
var Text = DataSet_City.Tables[0].Rows[i].Text;//必须和DataSet的列名一致
var Value = DataSet_City.Tables[0].Rows[i].Value;
DDL_City.options.add(new Option(Text,Value));
}
}
else
{
var DDL_Area = document.getElementById("Area");
DDL_Area.length = 0;
}
}
//绑定Area
function BindToArea(CityID,DDL_Area_ID)
{
var DataSet_Area = _Default.BindToArea(CityID).value;
var DDL_Area = document.getElementById(DDL_Area_ID);
DDL_Area.length = 0;
var Length = DataSet_Area.Tables[0].Rows.length;
for(var i=0;i<Length;i++)
{
var Text = DataSet_Area.Tables[0].Rows[i].Text;
var Value = DataSet_Area.Tables[0].Rows[i].Value;
DDL_Area.options.add(new Option(Text,Value));
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>请选择您所在的省:
<asp:DropDownList ID="Province" runat="server">
</asp:DropDownList>
请选择您所在的市:
<asp:DropDownList ID="City" runat="server">
</asp:DropDownList>
请选择您所在的区:
<asp:DropDownList ID="Area" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
cs:
using System;
using System.Data;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
this.BindToDDL();
}
//获得DataSet方法
private DataSet GetDS(string SqlString)
{
SqlConnection con = new SqlConnection("server=.;database=ProvinceCityArea;uid=sa;pwd=;