protected void Page_Load(object sender, EventArgs e) { if (Session["strNombreUsuario"] == null) { Response.Redirect("login.aspx"); } try { Response.Buffer = true; DataContext dcTemp = new DcGeneralDataContext(); if (!this.IsPostBack) { List <CatEstadoUser> lista = dcTemp.GetTable <CatEstadoUser>().ToList(); CatEstadoUser catTemp = new CatEstadoUser(); catTemp.id = -1; catTemp.strValor = "Todos"; lista.Insert(0, catTemp); this.ddlSexo.DataTextField = "strValor"; this.ddlSexo.DataValueField = "id"; this.ddlSexo.DataSource = lista; this.ddlSexo.DataBind(); } } catch (Exception _e) { var mensaje = "Error message: " + _e.Message; if (_e.InnerException != null) { mensaje = mensaje + " Inner exception: " + _e.InnerException.Message; } mensaje = mensaje + " Stack trace: " + _e.StackTrace; this.Response.Redirect("~/PageError.aspx", false); } }
protected void ddlCatEstadoUser_SelectedIndexChanged(object sender, EventArgs e) { try { int idCatUsuario = int.Parse(this.ddlCatEstadoUser.Text); Expression <Func <CatEstadoUser, bool> > predicateCatU = c => c.id == idCatUsuario; predicateCatU.Compile(); List <CatEstadoUser> lista = dcGlobal.GetTable <CatEstadoUser>().Where(predicateCatU).ToList(); CatEstadoUser catTemp = new CatEstadoUser(); this.ddlCatEstadoUser.DataTextField = "strValor"; this.ddlCatEstadoUser.DataValueField = "id"; this.ddlCatEstadoUser.DataSource = lista; this.ddlCatEstadoUser.DataBind(); } catch (Exception) { this.showMessage("Ocurrio un error inesperado"); } }