作者Turbine (特而)
看板C_Sharp
标题[问题] 抓取DropDownList的值
时间Wed Jan 31 21:34:57 2007
想请问一下
我希望知道user选择哪各option
然後把他存在字串select
显示出来
但不知道哪里写错了@@
<%@ Page Language="C#" %>
<%@ Import NameSpace="System.Collections" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
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
1F:推 coign:给它个出口吧!Label1.Text = select; 02/01 23:06
2F:→ coign:还有postback问题 & string select = "no";摆放处问题 02/01 23:18
3F:推 Turbine:请问一下 我string摆那边是当作instance变数 02/02 08:29
4F:→ Turbine:想不出哪里错 Orz 02/02 08:30
5F:→ coign:ok~不好意思!那就前两个问题解决了就ok罗~~ 02/02 14:19