日期:2014-05-18 浏览次数:20526 次
<asp:DropDownList ID="DDLProvince" runat="server" CssClass="select"
AutoPostBack="True" Height="22px"
onselectedindexchanged="DDLProvince_SelectedIndexChanged" Width="150px">
</asp:DropDownList>
<asp:DropDownList ID="DDLCity" runat="server" CssClass="select"
CausesValidation="True" Height="19px" Width="150px">
</asp:DropDownList>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RegionalInformation ri = new RegionalInformation();
string[][] allProvinces = ri.GetProvinces();
for (int i = 0; i < allProvinces.Length; i++)
{
ListItem lip = new ListItem(allProvinces[i][1], allProvinces[i][0]);
DDLProvince.Items.Add(lip);
}
}
}
protected void DDLProvince_SelectedIndexChanged(object sender, EventArgs e)
{
RegionalInformation ri = new RegionalInformation();
string a = Convert.ToString(DDLProvince.SelectedIndex + 1);
string[][] citiesOfProvince = ri.GetCitiesOfProvince(a);
for (int j = 0; j < citiesOfProvince.Length; j++)
{
ListItem li = new ListItem(citiesOfProvince[j][1], citiesOfProvince[j][0]);
DDLCity.Items.Add(li);
}
}