<asp:DropDownList ID="dropdownCountry" runat="server"
CssClass="form-control form-control-dropdown"
OnSelectedIndexChanged="dropdownCountry_SelectedIndexChanged"
EnableViewState="true" AutoPostBack="true">
</asp:DropDownList>
protected void dropdownCountry_SelectedIndexChanged(object sender, EventArgs e)
{
var countryId = Convert.ToInt32(dropdownCountry.SelectedValue);
var states = from st in model.states
where st.CountryId == countryId
select st;
dropdownState.DataValueField = "StateId";
dropdownState.DataTextField = "State1";
dropdownState.DataSource = states;
DataBind();
}
我设置了EnableViewState="true"
和AutoPostBack="true"
两个值。我的页面加载事件被触发但dropdownCountry_SelectedIndexChanged
未被触发
答案 0 :(得分:-2)
在Page_Load
上使用!Page.IsPostBack