private void fill_drpdwn() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Departments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_ID", Session["User_ID"].ToString()); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Drp_Dept.DataSource = ds.Tables[0]; Drp_Dept.DataValueField = "Dept_Name"; Drp_Dept.DataBind(); con.Close(); Drp_Dept.Items.Insert(0, new ListItem("--Select Department--", "0")); Drp_User_Group.Items.Insert(0, new ListItem("--Select User Group--", "0")); Drp_User.Items.Insert(0, new ListItem("--Select User--", "0")); Drp_Exp.SelectedValue = "0"; Drp_Gender.SelectedValue = "0"; Drp_User_Type.SelectedValue = "0"; txt_Dt_of_Join.Text = ""; Chk_Lev1_Manager.Checked = false; Chk_Lev2_Manager.Checked = false; lblErrorMsg.Text = ""; } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
private void fill_drpdwn() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Departments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "Get_DeptByUser"); cmd.Parameters.AddWithValue("@User_ID", Session["User_ID"].ToString()); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Drp_Dept.DataSource = ds.Tables[0]; Drp_Dept.DataValueField = "Dept_Name"; Drp_Dept.DataBind(); con.Close(); Drp_Exp.SelectedValue = "0"; lblErrorMsg.Text = ""; } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }