看http://chs.gotdotnet.com/quickstart/aspplus/doc/webcontrolsref.aspx
解决方案 »
- WebService、WebApplication请教!!
- 跨网站登陆
- C#.net中如何保存带模版列(textBox)的数据
- 为什么我的JS脚本在有的机子上可以运行,有些机子上又报错,是不是每个机子上的JS版本不同啊
- 关于asp.net调试的问题,帮帮我啊
- 如何实现 UserControl 属性面板,以便更容易的修改属性!
- 初学Microsoft .NET Framework SDK v1.1,碰到两个问题,有请各位赐教!
- 关于在asp.net中调用数据库存储过程的问题请教:
- 值不能为空。参数名: s
- ASP。NET中的TREEVIEW的CHECKBOX,如果我多选了几个,我如何通过程序来知道那几个选了呀
- 关于datagrid的问题
- asp.net(c#)如何从数据库中读取数据并生成xml文件--在线等
<head>
<script language="C#" runat="server"> void SubmitBtn_Click(Object Sender, EventArgs e) {
Label1.Text="您选择了:" + DropDown1.SelectedItem.Text;
} </script></head>
<body> <h3><font face="宋体">DropDownList 示例</font></h3> <form runat=server> <asp:DropDownList id=DropDown1 runat="server">
<asp:ListItem>项 1</asp:ListItem>
<asp:ListItem>项 2</asp:ListItem>
<asp:ListItem>项 3</asp:ListItem>
<asp:ListItem>项 4</asp:ListItem>
<asp:ListItem>项 5</asp:ListItem>
<asp:ListItem>项 6</asp:ListItem>
</asp:DropDownList> <asp:button text="提交" OnClick="SubmitBtn_Click" runat=server/> <p>
<asp:Label id=Label1 font-name="宋体" font-size="10.5pt" runat="server">
从列表中选择一个值
</asp:Label> </form></body>
</html>
<head>
<script language="C#" runat="server"> void Page_Load(Object Sender, EventArgs E) { if (!IsPostBack) { ArrayList values = new ArrayList(); values.Add ("IN");
values.Add ("KS");
values.Add ("MD");
values.Add ("MI");
values.Add ("OR");
values.Add ("TN"); DropDown1.DataSource = values;
DropDown1.DataBind();
}
} void SubmitBtn_Click(Object sender, EventArgs e) {
Label1.Text = "您选择了:" + DropDown1.SelectedItem.Text;
} </script></head>
<body> <h3><font face="宋体">数据绑定 DropDownList</font></h3> <form runat=server>
<asp:DropDownList id="DropDown1" runat="server" /> <asp:button Text="提交" OnClick="SubmitBtn_Click" runat=server/> <p>
<asp:Label id=Label1 font-name="宋体" font-size="10.5pt" runat="server" /> </form></body>
</html>
'数据库名为本地SQL中的users
'department 为users库中的一个表,它包含"department、departmentID"两个字段
'Dropdownlist 显示的是department字段的值。Public Sub dp1_DataBind()
Dim myconnection As SqlClient.SqlConnection
Dim mycommand As SqlClient.SqlCommand
myConnection = New SqlClient.SqlConnection("server=localhost;database=users;uid=sa;Password=123456;")
myCommand = New SqlClient.SqlCommand("SELECT * From department", myConnection)
myConnection.Open()
Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader()
Me.DropDownList1.DataSource = myDataReader
Me.DropDownList1.DataTextField = "department"
Me.DropDownList1.DataValueField = "departmentID"
Me.DropDownList1.DataBind()
Me.myConnection.Close() End Sub