⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dropdown.aspx

📁 This is not a very mean things
💻 ASPX
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>
<title>The DropDownList Control</title>
<style>
  hr		{height:2px;color:black;}
  .StdText	{font-family:verdana;font-size:9pt;}
</style> 


<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
	// Initialize only the first time...
	if (!Page.IsPostBack)
	{
		lblURL.Text = Request.Url + "<hr>";

		// Populates the combobox from an array
		ArrayList a = new ArrayList();
		a.Add("Yellow");
		a.Add("Green");
		a.Add("Blue");
		a.Add("Red");
		DDList.DataSource = a;
		
		// Get some data from Northwind
		String strConn, strCmd;
		strConn = "DATABASE=Northwind;SERVER=localhost;UID=sa;PWD=;";
		strCmd = "SELECT employeeid, firstName, lastname FROM Employees";
		SqlDataAdapter oCMD = new SqlDataAdapter(strCmd, strConn);
		DataSet oDS = new DataSet();
		oCMD.Fill(oDS, "EmployeesList");

		// Add a new precalculated column 
		DataTable dt = oDS.Tables["EmployeesList"];
		dt.Columns.Add("EmployeeName", typeof(String), "lastname + ', ' + firstname"); 
		
		EmpList.DataSource = oDS.Tables["EmployeesList"].DefaultView;
		EmpList.DataTextField = "EmployeeName";
		EmpList.DataValueField = "employeeid";		
	}
	
	// (re)Bind all controls in the page
	Page.DataBind();
}
</script>


<body bgcolor="ivory" style="font-family:arial;font-size:9pt">

<!-- ASP.NET topbar -->
<h2>The DropDownList Control</h2>
<asp:Label runat="server" cssclass="StdText" font-bold="true">Current path: </asp:label>
<asp:Label runat="server" id="lblURL" cssclass="StdText" style="color:blue"></asp:label>

<form runat=server>
    <asp:dropdownlist autopostback="true" runat="server" id="DDList" cssclass="stdtext" /> 
    <asp:Label id="Statusbar" runat="server"  text='<%# "<b>Selected:</b> " + DDList.SelectedItem.Text %>' />
    
    <hr>

    <asp:dropdownlist autopostback="true" runat="server" id="EmpList" cssclass="stdtext" />
    <asp:Label id="EmpID" runat="server"  text='<%# "<b>Employee ID:</b> " + EmpList.SelectedItem.Value %>' />
</form>

</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -