<
asp:DropDownList
ID
=
"ddlEmployees"
runat
"server"
AutoPostBack
"true"
OnSelectedIndexChanged
"OnSelectedIndexChanged_ddlEmployees"
>
</
br
/>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!
this
.IsPostBack)
.PopulateDropDownList();
}
private
PopulateDropDownList()
string
constr = ConfigurationManager.ConnectionStrings[
"ConString"
].ConnectionString;
using
(SqlConnection con =
new
SqlConnection(constr))
(SqlCommand cmd =
SqlCommand(
"SELECT FirstName,EmployeeID FROM Employees"
, con))
(SqlDataAdapter da =
SqlDataAdapter(cmd))
con.Open();
DataSet ds =
DataSet();
da.Fill(ds);
.ddlEmployees.DataTextField =
"FirstName"
;
.ddlEmployees.DataValueField =
"EmployeeID"
.ddlEmployees.DataSource = ds;
.ddlEmployees.DataBind();
.ddlEmployees.Items.Insert(0,
System.Web.UI.WebControls.ListItem(
" --Select Please-- "
,
"0"
));