我添加了一个DropDownList,在其SelectedIndexChanged中写了如下代码,但没有反映,请高手指导private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text="您选择的学校是:"+DropDownList1.SelectedItem.Text;
}
{
Label1.Text="您选择的学校是:"+DropDownList1.SelectedItem.Text;
}
runat="server" AutoPostBack="True"></asp:DropDownList>
记得
AutoPostBack="True"还要记得在 page_load中加入if not ispostback then
end if
DropDownList1.AutoPostBack = true ;
试试
{
if(!IsPostBack)
{
//该页面初始化的代码
}
//可以加你在响应事件和初始化时一同实现的代码}private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text="您选择的学校是:"+DropDownList1.SelectedItem.Text;
}
还要注意页面回发
AutoPostBack="True"