• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

asp.NET省市聯動菜單

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

 所在省市:<asp:DropDownList ID="ddlProvince" runat="server" AutoPostBack="true"                   OnSelectedIndexChanged="ddlProvince_SelectedIndexChanged"></asp:DropDownList>
           <asp:DropDownList ID="ddlCity" runat="server"></asp:DropDownList>
---------------------------------------------------------------------------------------
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dataBindToProv();              
                   SqlDataReader sdr = ADRelease.BLL.Enterprise.GetEnterpriseInfo(EnterpriseID);
                    if (sdr.Read())
                    {
                        tbWebName.Text = sdr["WebName"].ToString();
                        tbWebIntro.Text = sdr["WebIntro"].ToString();
                        tbMainBusiness.Text = sdr["MainBusiness"].ToString();
                        tbDomainName.Text = sdr["DomainName"].ToString();
                        tbContactMan.Text = sdr["ContactMan"].ToString();
                        tbContactPhone.Text = sdr["ContactPhone"].ToString();
                        tbFaxNumber.Text = sdr["FaxNumber"].ToString();
                        tbEmail.Text = sdr["Email"].ToString();
                        ddlProvince.SelectedIndex = ddlProvince.Items.IndexOf(ddlProvince.Items.FindByValue(Convert.ToString(sdr["ProvinceID"])));
                        //关键下面两句
                        dataBindToCity();
                        ddlCity.SelectedItem.Text = sdr["City"].ToString();   
               
                        imgLogo.ImageUrl = "../images/logoUpLoad/" + sdr["logo"].ToString();
                        lblPath.Text = sdr["logo"].ToString();
                    }
                    sdr.Close();                   
            }        
           
        }
        //绑定省的下拉
        public void dataBindToProv()
        {
            SqlDataReader sdr1 = ADRelease.BLL.Enterprise.GetProvinceInfo();          
             this.ddlProvince.DataSource = sdr1;
            this.ddlProvince.DataTextField = "ProvinceName";
             this.ddlProvince.DataValueField = "ProvinceID";
             this.ddlProvince.DataBind();
             sdr1.Close();
        }
        //绑定城市下拉
        public void dataBindToCity()
        {
            SqlDataReader sdr2 = ADRelease.BLL.Enterprise.GetCityInfo(int.Parse(this.ddlProvince.SelectedValue.ToString()));
            this.ddlCity.DataSource = sdr2;
           this.ddlCity.DataTextField = "CityName";
            this.ddlCity.DataValueField = "CityID";
            this.ddlCity.DataBind();
            sdr2.Close();
        }

        protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataBindToCity();
        }    

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap