DropDownList and Array example: populating a DropDownList with Array DataSource
ArrayDropDownListExample.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e) {
string[] DataToolBoxArray = new string[13] { "ListView", "GridView", "DetailsView", "FormView", "Repeater", "DataList", "LinqDataSource", "EntityDataSource", "SqlDataSource", "AccessDataSource", "ObjectDataSource", "XmlDataSource", "SiteMapDataSource" };
DropDownList1.DataSource = DataToolBoxArray;
DropDownList1.DataBind();
Label1.Text = "DataToolBox Controls<br />";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DropDownList and Array example: populating a DropDownList with Array DataSource</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">Using Array in DropDownList</h2>
<asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DarkBlue"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<br /><br />
<asp:Button ID="Button1" runat="server" Text="Populate DropDownList" OnClick="Button1_Click" Font-Bold="true" ForeColor="DarkGreen" />
</div>
</form>
</body>
</html>
- asp.net RadioButton: how to use
- asp.net BulletedList: how to use
- asp.net ListBox: how to use Multiple SelectionMode
- asp.net ListBox: how to use
- asp.net DropDownList: how to use
- asp.net SqlCommand() example: how to build SQL dynamically
- asp.net example: get the ConnectionStrings List programmatically
- HyperLink Control example: how to use HyperLink in asp.net
- Session Example: how to use Session in asp.net
- How to create and use User Control in asp.net