问题描述
嗨
i有2个下拉列表,onselectedindexchanged和autopostback true
当我点击dropdown1页面重新加载时,当前选择listitem是selectbox中的默认值..,我根据dropdown1值从数据库填充dropdown2 ..
然后当我点击dropdown2时,页面重新加载但是dropdown2选择的索引保持为0或空白
什么是错误
Hi
i have 2 dropdown with onselectedindexchanged and autopostback true
when i click dropdown1 the page reloads ,and current select listitem is default in selectbox.., i fill dropdown2 from database depending on dropdown1 value..
then when i click dropdown2 ,page reloads but the dropdown2 selected index remains 0 or blank
what is error
<asp:DropDownList ID="DropCity" AutoPostBack="True" onselectedindexchanged="DropCity_SelectedIndexChanged" runat="server" >
</asp:DropDownList>
<asp:DropDownList ID="DropCity1" AutoPostBack="True" onselectedindexchanged="DropCity1_SelectedIndexChanged" runat="server" >
</asp:DropDownList>
protected void DropCity1_SelectedIndexChanged(object sender, EventArgs e)
{
DropCity.DataSource();
DropCity.databing();
}
DropCity.DataSource();
DropCity.databing();
}
protected void DropCity_SelectedIndexChanged(object sender, EventArgs e)
{
}
请建议
}
please advice
推荐答案
drp1.DataTextField = "Test1";
drp1.DataValueField = "TestID";
drp1.DataSource = dt;
drp1.DataBind();
这篇关于dropdown SelectedIndexChanged页面重新加载但值为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!