DropDownList and Update Panel

前端 未结 2 1490
清歌不尽
清歌不尽 2021-01-22 07:51

I develop address control, which contains 2 DropDownLists (for cities and countries) and several TextBoxes. The second DropDownList DataSource depends on the first DropDownList

相关标签:
2条回答
  • 2021-01-22 08:21

    Move the code on Page_Init to Page_Load and put it inside !IsPostBack

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ddlCountry.DataBind();
            ddlCity.DataSource = Facade.Addresses.GetCities(countryId);
            ddlCity.DataBind();
        }
    }
    
    0 讨论(0)
  • 2021-01-22 08:24

    put ddlCountry.DataBind(); inside if condition

    0 讨论(0)
提交回复
热议问题