selectdvalue selecteditem.value selecteditem.text 好混淆,究竟是什么东西呢? selectdvalue selecteditem.value selecteditem.text 好混淆,究竟是什么东西呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DropDownList.SelectedItem.Text 和 DropDownList.SelectedValue <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { MessageOne.Text = "来自" + DropDownListCity.SelectedItem.Text +"的" + TextBoxName.Text ; //DropDownListCity.SelectedItem.Text 的内容是 <asp:ListItem Value ="GaoLaoZhuang">高老庄</asp:ListItem>中间的"高老庄" MessageTwo.Text = "来自" + DropDownListCity.SelectedValue +"的" + TextBoxName.Text; //DropDownListCity.SelectedValue 是<asp:ListItem Value ="GaoLaoZhuang">中的Value中指定的值. MessageThree.Text = "来自" + DropDownListCity.SelectedItem.Value + "的" + TextBoxName.Text; //DropDownList.SelectedItem.Value 和 DropDownList.SelectedValue 是一样的. }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>ASP.NET学习001</title></head><body> <form id="form1" runat="server"> <asp:TextBox ID="TextBoxName" runat="server"/> <asp:DropDownList ID="DropDownListCity" runat="server"> <asp:ListItem Value ="GaoLaoZhuang">高老庄</asp:ListItem> <asp:ListItem Value ="TianPengYuanShuaiFu">天蓬元帅府</asp:ListItem> </asp:DropDownList> <asp:Button ID="Button1" runat="server" Text="确定" /> <br /> <asp:Label ID="MessageOne" runat="server" /> <br /> <asp:Label ID="MessageTwo" runat="server" /> <br /> <asp:Label ID="MessageThree" runat="server" /> </form></body></html> SelectedItem.Value和SelectedValue功能差不多,还是有区别的,如果没有一个List Item被选中,那么SelectedItem.Value将会报错,SelectedValue的值为空字符串。 selectdvalue貌似是JS取的? 比如一个DropDownList 属性 说明 Text 列表中显示的文本。 Value 与某个项关联的值。设置此属性可使您将该值与特定的项关联而不显示该值。 Selected 布尔值,指示该项是否被选定。 DropDownList 控件的 Items 是一个标准集合,您可以向它添加项对象。selecteditem就是指你选定的项。selecteditem.text 就是选定项的文本。selecteditem.value 就是选定项的关联值。例如我们可以用text 显示人名,而value值绑定人员的id。selectedvaule就是直接指你选定的关联值。(vs2005中才有,vs2003中没有) 求类似csdn这样的验证码源码 前台通过<%%>,后台调用 如何获取http://www.ip.cn/里查到的ip地址? 关于用html生成table 一段用jmail发邮件的代码出错,请各位帮忙。 用正则表达式控制输入框只能输入39码允许范围以内的字符 在动态生成的TabPanel和GridView中,取得每个GridView中CheckBox选中的个数 100分~~来者有分~~! 数据绑顶问题! 怎样把数据表的某段绑在DropDownList中 求准确答案! 正则获取www.qq.com/nba.qq.com
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
MessageOne.Text = "来自" + DropDownListCity.SelectedItem.Text +"的" + TextBoxName.Text ;
//DropDownListCity.SelectedItem.Text 的内容是 <asp:ListItem Value ="GaoLaoZhuang">高老庄</asp:ListItem>中间的"高老庄"
MessageTwo.Text = "来自" + DropDownListCity.SelectedValue +"的" + TextBoxName.Text;
//DropDownListCity.SelectedValue 是<asp:ListItem Value ="GaoLaoZhuang">中的Value中指定的值. MessageThree.Text = "来自" + DropDownListCity.SelectedItem.Value + "的" + TextBoxName.Text;
//DropDownList.SelectedItem.Value 和 DropDownList.SelectedValue 是一样的.
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET学习001</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBoxName" runat="server"/>
<asp:DropDownList ID="DropDownListCity" runat="server">
<asp:ListItem Value ="GaoLaoZhuang">高老庄</asp:ListItem>
<asp:ListItem Value ="TianPengYuanShuaiFu">天蓬元帅府</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="确定" />
<br />
<asp:Label ID="MessageOne" runat="server" />
<br />
<asp:Label ID="MessageTwo" runat="server" />
<br />
<asp:Label ID="MessageThree" runat="server" />
</form>
</body>
</html>
SelectedItem.Value和SelectedValue
功能差不多,还是有区别的,如果没有一个List Item被选中,那么SelectedItem.Value将会报错,SelectedValue
的值为空字符串。
貌似是JS取的?
Text 列表中显示的文本。
Value 与某个项关联的值。设置此属性可使您将该值与特定的项关联而不显示该值。
Selected 布尔值,指示该项是否被选定。 DropDownList 控件的 Items 是一个标准集合,您可以向它添加项对象。selecteditem就是指你选定的项。
selecteditem.text 就是选定项的文本。
selecteditem.value 就是选定项的关联值。
例如我们可以用text 显示人名,而value值绑定人员的id。selectedvaule就是直接指你选定的关联值。(vs2005中才有,vs2003中没有)