我在网页上有两个下拉列表(StateNames& CityNames)。 我想绑定CityNames取决于所选的StateName。 我编写了BindCities()函数来绑定CityNames下拉列表。 通过使用Dictionary,我将绑定这些下拉列表。
private void BindCity() {
try {
string Action = "BindCity";
int CompanyId = 1;
int StateId = Convert.ToInt32(ddlPresentState.SelectedValue);
Dictionary<int, string> dct = AppBll.BindCityNames(Action, CompanyId, StateId);
ddlPresentCity.DataSource = dct;
ddlPresentCity.DataValueField = "Key";
ddlPresentCity.DataTextField = "Value";
ddlPresentCity.DataBind();
}
catch (Exception) {
throw;
}
}
现在我想从StateNames下拉列表的JavaScript OnChange事件中调用BindCities()函数。 但它没有用。 所以请帮我解决这个问题。 提前谢谢。
答案 0 :(得分:0)
<强> ASPX 强>
<asp:DropDownList runtat="server" Id="StateNames"
OnChange="StateNames_OnSelectedIndexChanged"></asp:DropDownList >
<强> CS 强>
public void StateNames_OnSelectedIndexChanged(object sender, EventArgs args)
{
BindCities();
}