我已经将某数据表的所有列名添加到了DropDownList中了,但是如何将选定的值赋给Label呢。
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Value;
}这样为什么不可以阿,请指教。
谢谢!
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Value;
}这样为什么不可以阿,请指教。
谢谢!
解决方案 »
- 关于.net读取xml的问题
- 问安装程序的一个小问题!!
- 网站动态生成菜单问题
- **************************请问关于文件下载的问题**************************
- 为什么验证控件在本地的时使用是可以的,但发到网上的服务器上就不起作用了?
- vs2003中 关闭弹出页面刷新原页面
- 这句话“dataReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);”表示什么意思呢?实现了什么功能呢?
- 高分求asp.net(C#语言的)获得客户端硬盘序列号源代码
- ~~~! ASP.NET在HTML设计的问题
- 如何做虚拟目录访问统计
- 求C#的文本编辑器
- 设置IIS后出现错误,如何解决
你要设定事件才能触发啊~选择改变后label1的文本绑定才可以
Label1.Text = DropDownList1.SelectedItem.Value;
Label1.Text = DropDownList1.SelectedValue;
要想 DropDownList1_SelectedIndexChanged 事件发生
需要将 DropDownList1的AutoPostBack=TRUE用Label1.Text = DropDownList1.SelectedItem.Text;
或者
Label1.Text = DropDownList1.SelectedItem.Value;
过此时 value 属性得有值哦
DropDownList1.AutoPostBack要设为true
dropdownlist1.selectitem.text....是文本dropdownlist1.items.add(new listitem("文本","值"))