[問題] 抓取DropDownList的值
想請問一下
我希望知道user選擇哪各option
然後把他存在字串select
顯示出來
但不知道哪裡寫錯了@@
<%@ Page Language="C#" %>
<%@ Import NameSpace="System.Collections" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
ArrayList al = new ArrayList();
public void Page_Load(Object obj, EventArgs e){
al.Add("1");
al.Add("2");
al.Add("3");
DropDownList1.DataSource = al;
DropDownList1.DataBind();
}
string select ="no" ;
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
select = DropDownList1.SelectedValue;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
Style="z-index: 100; left: 74px; position: absolute; top: 105px">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Style="z-index: 102; left: 79px; position: absolute;
top: 154px" Text='<%#select %>'></asp:Label>
</div>
</form>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.130.182.221
推
02/01 23:06, , 1F
02/01 23:06, 1F
→
02/01 23:18, , 2F
02/01 23:18, 2F
推
02/02 08:29, , 3F
02/02 08:29, 3F
→
02/02 08:30, , 4F
02/02 08:30, 4F
→
02/02 14:19, , 5F
02/02 14:19, 5F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章