请问怎么读取下拉菜单dropdownlist的值呢 在线等!!
做了个网站 用下拉添加的时间 可是要修改的话读出来的不是数据库的 要怎么读才能叫值显示在上面 而不是默认的第一个值
麻烦告诉下
[解决办法]
Request.Form(dropdownlistId.UniqueID)
[解决办法]
this.dropdownlist.SelectedItem.Text
[解决办法]
我用的是 c#
获取到你 数据库的 时间
转换为 dropdownlist 里面有的项 文字一样 在赋值就可以了
this.dropdownlist.SelectedItem.Text= "2007 ";
2007 是你 dropdownlist 存在的一项的文字
[解决办法]
<form id= "Form1 " method= "post " runat= "server ">
<asp:Button id= "Button1 " runat= "server "
Text= "Button "> </asp:Button>
<asp:DropDownList id= "DropDownList1 " runat= "server ">
<asp:ListItem Value= "aaaaa "> aaaaa </asp:ListItem>
<asp:ListItem Value= "bbbb "> bbb </asp:ListItem>
</asp:DropDownList>
</form>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Request.Form(DropDownList1.UniqueID))
End Sub
[解决办法]
<body>
<script>
var i = 0;
</script>
<form id= "Form1 " method= "post " runat= "server ">
<asp:DropDownList id= "DropDownList1 " runat= "server ">
<asp:ListItem Value= "aaaaa "> aaaaa </asp:ListItem>
<asp:ListItem Value= "bbbb "> bbb </asp:ListItem>
</asp:DropDownList>
<input type= "button " value= "添加 " onclick= "DropDownList1.options[DropDownList1.options.length] = new Option(++i,i,true,true) ">
<asp:Button id= "Button1 " runat= "server " Text= "Button "> </asp:Button>
</form>
</body>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Request.Form(DropDownList1.UniqueID))
End Sub
[解决办法]
就是说,你自己通过js,ajax等添加的只能用Form(表单名字)接收