private void fill_Doc_Type_drpdwn() { using (SqlConnection con = new SqlConnection(constr.getconstr())) { using (SqlCommand cmd = new SqlCommand("SELECT Doc_Type FROM Document_Type")) { cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); Drp_Doc_Type.DataSource = cmd.ExecuteReader(); Drp_Doc_Type.DataValueField = "Doc_Type"; Drp_Doc_Type.DataBind(); con.Close(); } } Drp_Doc_Type.Items.Insert(0, new ListItem("--Select Doc Type--", "0")); Drp_Sub_Doc_Type.Items.Insert(0, new ListItem("--Select Sub Doc Type--", "0")); }
private void fill_Doc_Type_drpdwn() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Doc_Type", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "View"); cmd.Parameters.AddWithValue("@Dept_Name", Drp_Dept.SelectedValue); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Drp_Doc_Type.DataSource = ds.Tables[0]; Drp_Doc_Type.DataValueField = "Doc_Type"; Drp_Doc_Type.DataBind(); con.Close(); Drp_Doc_Type.Items.Insert(0, new ListItem("All", "99")); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }