不知道是不是我逻辑的问题,我这是一个登录界面,可以再DropDownList里面选择身份是学生和管理员,我想实现当DropDownList选项是学生时,页面能够多两个label和新的DropDownList。但是页面运行时这两个label并没有出现。是把这两个label的初始Visible设为false。在 DropDownList1_SelectedIndexChanged里面写:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "学生")
{
this.Label5.Visible = true;
this.Label6.Visible = true;
this.DropDownList2.Visible = true;
this.DropDownList3.Visible = true; }
}
可是改变选项时,并没有出现应有的结果,是不是应该让页面刷新一下?重新刷新页面的代码是啥啊?
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "学生")
{
this.Label5.Visible = true;
this.Label6.Visible = true;
this.DropDownList2.Visible = true;
this.DropDownList3.Visible = true; }
}
可是改变选项时,并没有出现应有的结果,是不是应该让页面刷新一下?重新刷新页面的代码是啥啊?
解决方案 »
- 关于定义委托类型参数的问题!
- combox中如何查找确定ValueMember的值
- report service作的报表 能否接受DataTable参数
- 求助C#中读取剪切板中的html中文乱码问题
- C#中Datatable的使用问题!
- 输入 10+11*12+16/4 求结果
- 连接POP3服务器出错: -ERR Logon Failure
- 如何设置窗体中文本框的内容
- 我在用WebClient向一个网站POST一个字符串,报出这么一个错误,请问高手是什么意思啊?
- 未处理的“System.Threading.ThreadStateException”类型的异常出现在 system.windows.forms.dll 中
- 怎么通过选择的文件获得它的绝对路径
- gridview在RowCommand事件里怎么找没有被显示在控件里的字段
if (DropDownList1.SelectedValue == "学生")
这行设置断点,运行,改变 DropDownList 选择,看看断点有没被中断,也就是事件有没被触发,如果触发再看选择“学生”时 DropDownList1.SelectedValue 的值是什么,是否满足 if 的条件。
<asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True"></asp:DropDownList>
这个设置了吗?