1.建立一个aspx页面,html代码
http://www.w3.org/1999/xhtml " >
fungsi buatXMLHttpRequest()
{
jika (jendela.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
lain jika (window.XMLHttpRequest)
{
xmlHttp = XMLHttpRequest baru();
}
}
fungsi mulaiPermintaan()
{
//debug;
var ProvinceID=document.getElementById("DropDownList1");
buatXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "?ProvinceID="+ProvinceID.value, true);
xmlHttp.kirim(null);
}
fungsi handleStateChange()
{
if(xmlHttp.readyState == 4) //0(未初始化);1(正在装载);2 (装载完毕);3 (交互中);4 (完成)
{
if(xmlHttp.status == 200) //200(OK);404(tidak ditemukan)
{
document.getElementById("gridiv").innerHTML=xmlHttp.responseText;
}
}
}
properti#properti wilayah
string pribadi ProvinceID
{
mendapatkan
{
if (Permintaan["ProvinceID"] != null && Permintaan["ProvinceID"].ToString() != "")
{
permintaan pengembalian["ProvinceID"];
}
kalau tidak
{
kembali "";
}
}
}
#endregion
GetDataSet#region GetDataSet
Kumpulan Data pribadi GetDataSet(string sql)
{
string constring=Sistem.Konfigurasi.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,constring);
Kumpulan Data ds=Set Data baru();
sda.Isi(ds);
kembali ds;
}
#endregion
GetCityByProvinceID#region GetCityByProvinceID
kekosongan pribadi GetCityByProvinceID (string ProvinceID)
{
string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
Sambungan SqlConnection = SqlConnection baru(sambunganStr);
string sql = "pilih * dari kota dimana ayah='" + ID Provinsi + "'";
SqlCommand cmd = new SqlCommand(sql, samb.);
samb.Buka();
SqlDataReader dr = cmd.ExecuteReader();
string s = @"
流水号 | 代号 | 城市 |
---|---|---|
" + dr["id"] + " | ";" + dr["ID kota"] + " | ";" + dr["kota"] + " | ";