Three-level linkage of provincial and municipal level implemented with DropDownList

Source: Internet
Author: User

This is a DropDownList implementation of the provincial and municipal level three linkage, record the

<asp:scriptmanager id= "ScriptManager1" runat= "Server" >/asp:ScriptManager>
<asp:updatepanel id= "UpdatePanel1"  runat= "Server" >                           <contenttemplate><p><span class= "Redcolor" >* </span> Select a region:                           <asp:dropdownlist id= "Provinceselect"  autopostback= "True"  &nbs p;runat= "Server"  onselectedindexchanged= "Getcityname_onclick" ></asp:dropdownlist><asp:d ropdownlist runat= "Server"  id= "Cityselect"  autopostback= "True"  onselectedindexchanged= " Getcounty_onclick "  ></asp:dropdownlist><asp:dropdownlist   autopostback= "True"  runat= "Server"  id= "County" ></asp:DropDownList></p>                        </ contenttemplate>                          <Triggers>                              <asp:asyncpostbacktrigger controlid= "Provinceselect"  EventName= " SelectedIndexChanged " />                         </Triggers>
</asp:UpdatePanel>

Background code:

protected void Page_Load (object sender, EventArgs e)        {            if (!  IsPostBack)            {                Provinceselect.datasource = BFL. Getprivoces ();                Provinceselect.datatextfield = "Regionname";                Provinceselect.datavaluefield = "RegionID";                Provinceselect.databind ();                ProvinceSelect.Items.Insert (0, New ListItem ("Please select", String.) Empty)); CitySelect.Items.Insert (0, New ListItem ("Please select", String.) Empty)); County.Items.Insert (0, New ListItem ("Please select", String.) Empty));  } }

#region Provinces and Cities data binding//city-bound public void Getcityname_onclick (object sender, EventArgs e) {citys Elect. DataSource = BFL. Getcitys (int.            Parse (ProvinceSelect.SelectedItem.Value));            Cityselect.datatextfield = "Regionname";            Cityselect.datavaluefield = "RegionID";            Cityselect.databind (); County.Items.Insert (0, New ListItem ("Please select", String.)        Empty)); }
County-bound public void Getcounty_onclick (object sender, EventArgs e) {county.datasource = BFL. Getcitys (int.            Parse (CitySelect.SelectedItem.Value));            County.datatextfield = "Regionname";            County.datavaluefield = "RegionID";            County.databind (); County.Items.Insert (0,new ListItem ("Please select", String.)        Empty)); } #endregion

Three-level linkage of provincial and municipal level implemented with DropDownList

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.