I try to update the ddlBuilding but it don't show anything . and ddlBuilding show nothing too .( work without UpdatePanel it show is ok.)
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div class="form-group col-md-12">
<label for="name">PCCC</label>
<asp:DropDownList ID="ddlDistrict" runat="server" CssClass="form-control select2 select2-hidden-accessible" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
</div>
<div class="form-group col-md-12">
<label for="name">Building</label>
<asp:DropDownList ID="ddlBuilding" runat="server" class="form-control select2 select2-hidden-accessible">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
Code behind .
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDistrict();
}
}
void FillDistrict()
{
DataTable district = Instant.GetAllDistrict();
ddlDistrict.DataSource = district;
ddlDistrict.DataValueField = "id";
ddlDistrict.DataTextField = "district_name";
ddlDistrict.DataBind();
}
protected void ddlDistrict_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable buildingz = Instant.GetBuildingByDistrictID(int.Parse(ddlDistrict.SelectedValue));
ddlBuilding.DataSource = buildingz;
ddlBuilding.DataValueField = "id";
ddlBuilding.DataTextField = "building_name";
ddlBuilding.DataBind();
}
sr my english is bad