protected void Page_Load(object sender, EventArgs e) { loademploeelist(); loaddepartmentlist(); } protected void loaddepartmentlist() { SqlConnection CON; SqlCommand COM; SqlDataReader READER; string ConnectionString = ConfigurationManager.ConnectionStrings["EMP"].ConnectionString; CON = new SqlConnection(ConnectionString); COM = new SqlCommand("Select department from dpmt", CON); try { CON.Open(); READER = COM.ExecuteReader(); dpmtList.DataSource = READER; dpmtList.DataValueField = "department"; dpmtList.DataBind(); READER.Close(); } catch { CON.Close(); } } protected void loademploeelist(); { SqlConnection CON; SqlCommand COM; SqlDataReader READER; string ConnectionString = ConfigurationManager.ConnectionStrings["EMP"].ConnectionString; CON = new SqlConnection(ConnectionString); if (dpmtList.Text == "Administrartor") { COM = new SqlCommand("Select Name,ID from AD",CON); } else if (dpmtList.Text == "hr") { COM = new SqlCommand("Select Name,ID from Her", CON); } else if (dpmtList.Text == "IT") { COM = new SqlCommand("Select Name,ID from IT", CON); } else { COM = new SqlCommand("Select Name,ID from HD",CON); } CON.Open(); READER = COM.ExecuteReader(); empList.DataSource = READER; empList.DataValueField = "ID"; empList.DataTextField = "Name"; empList.DataBind(); READER.Close(); CON.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { loademploeelist(); loaddepartmentlist(); } }
dpmtList.DataTextField = "department";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)