我有2個HtmlSelect控件,我需要根據第一個HtmlSelect的選定索引加載第二個。但它不起作用,因爲HtmlSelect不具有selectedindexchanged事件。我需要做什麼?任何想法?Htmlselect選擇索引更改事件
示例;
<!--These are my Html Select controls-->
select runat="server" id="drpCity"></select>
<select runat="server" id="drpState">/select>
protected void Page_Load(object sender, EventArgs e)
{
FillCities(drpCity);
FillStates(drpState, drpCity.SelectedValue);
}
public void FillCitiesHtmlSelect(HtmlSelect drpCity)
{
BusCity busCity = new BusCity();
List<EntCity> lentCity = busCity.SearchAll();
drpCity.DataValueField = EntCity.Columns.CITYCODE;
drpCity.DataTextField = EntCity.Columns.CITYNAME;
drpCity.DataSource = lentCity;
drpCity.DataBind();
drpCity.Items.Insert(0, new ListItem("City", string.Empty));
}
public void FillStatesHtmlSelect(HtmlSelect drpState, string cityCode)
{
if (!string.IsNullOrEmpty(cityCode))
{
BusState busState = new BusState();
List<EntState> lentEmsState = busState.Search(cityCode);
drpState.DataValueField = EntState.Columns.STATECODE;
drpState.DataTextField = EntState.Columns.STATENAME;
drpState.DataSource = lentState;
drpState.DataBind();
}
else
{
drpState.Items.Clear();
}
drpState.Items.Insert(0, "State", string.Empty));
}
謝謝你的回答,但我不擅長JavaScript。如果你有一個實用的代碼,那麼我可以應用它。我只是爲了這個,但沒有找到相關的例子。 – yunus