<%@ Register TagPrefix="Title" TagName="TitleShow" Src="/aspnetdata/Title.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web" %>
<html>
<head>
    <script language="C#" runat="server">
	OleDbConnection NowConn;
	DataSet DS =new DataSet();
	void Page_Load(object sender,EventArgs e){
		string x=Request.PhysicalPath; //取得路径及文件名
                                     string u=x.Remove(x.Length-12,12);
                                     string h="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + u + "post.mdb";
		NowConn = new OleDbConnection(h);
		if(IsPostBack==false){
		OleDbDataAdapter NComm = new OleDbDataAdapter("select * from city order by cityid", NowConn);
		NComm.Fill(DS, "city");
                                    // NConn.Close();
		AllCity.DataSource=DS.Tables["city"].DefaultView;
		AllCity.DataTextField="CityName";
		AllCity.DataValueField="CityID";
		AllCity.DataBind();//执行结合
		}
	}
	void showZipCode(Object sender,EventArgs e){
		TableRow nr;
		nr=new TableRow();
		TableCell nc;
		nc=new TableCell();
		nc.Text="乡镇区名称";
		nr.Cells.Add(nc);
		nc = new TableCell();
		nc.Text="邮递区号";
		nr.Cells.Add(nc);
		Zip.Rows.Add(nr);
		OleDbDataAdapter NComm1 = new OleDbDataAdapter("select * from CITYAREA where CityID = " + AllCity.SelectedItem.Value + " order by ZIPCode", NowConn);
		NComm1.Fill(DS, "CITYAREA");
		for(int i=0;i<=DS.Tables["CITYAREA"].Rows.Count-1;i++){
			nr = new TableRow();
			nc = new TableCell();
			nc.Text = DS.Tables["CITYAREA"].Rows[i]["CityAreaName"].ToString();
			nr.Cells.Add(nc);
			nc = new TableCell();
			nc.Text = DS.Tables["CITYAREA"].Rows[i]["ZIPCode"].ToString();
			nr.Cells.Add(nc);
			Zip.Rows.Add(nr);
		}
	}
    </script>
</head>
<body background="/aspnetdata/images/winback.gif">
<Title:TitleShow id="BookT" Runat="server" />
    <form runat="server">
<ASP:LABEL id="rr" runat="server" />
请选择县市：<asp:dropdownlist AutoPostBack="True" id="AllCity" OnSelectedIndexChanged="showZipCode"
runat="server" />
<asp:Table id="Zip" Font-Name="Verdana" Font-Size="10pt" CellPadding=3 CellSpacing=1 BorderColor="Red" BorderWidth="1" Gridlines="Both" runat="server"/>


</form>