protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string constr = ConfigurationManager.ConnectionStrings["CadenaConexion"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand CmdObtenerResponsables = new SqlCommand("ObtenerTipoDeUsuarios")) { CmdObtenerResponsables.Connection = con; CmdObtenerResponsables.CommandType = CommandType.StoredProcedure; using (SqlDataAdapter sdaObtenerResponsables = new SqlDataAdapter(CmdObtenerResponsables)) { DataTable dtObtenerResponsables = new DataTable(); sdaObtenerResponsables.Fill(dtObtenerResponsables); DropTipoUsuario.DataSource = dtObtenerResponsables; DropTipoUsuario.DataTextField = "TipoUsuario"; DropTipoUsuario.DataValueField = "Id"; DropTipoUsuario.DataBind(); DropTipoUsuario.Items.Insert(0, "(Seleccionar)"); } } } ObtenerUsuarios(); } }
private void llenarDropTipoUsuario() { SqlConnection con = new SqlConnection (System.Configuration.ConfigurationManager.ConnectionStrings["SAGES"].ToString()); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("Usuario_TraerTipo", con); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.Fill(ds); DropTipoUsuario.DataSource = ds; DropTipoUsuario.DataTextField = "tipoPerfil"; // FieldName of Table in DataBase DropTipoUsuario.DataValueField = "tipoPerfil"; DropTipoUsuario.DataBind(); }