private void FillGrid() { var userManager = new UserManager(ctx); var allUsers = userManager.GetUsers(); var farmManager = new FarmManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString); var farms = farmManager.GetAllFarmsForDropDown(); foreach (var user in allUsers) { var farm = farms.FirstOrDefault(x => x.Cod == user.UserCod); if (farm != null) { user.UserCod = farm.Cod + " - " + farm.Nume; } } lcount.Text = allUsers.Count + " useri"; UserGrid.DataSource = allUsers; UserGrid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var userManager = new UserManager(ctx); var user = userManager.GetUser(Request.Params["UserName"]); UserId.Value = user.UserId.ToString(); UserCod.Value = user.UserCod; UserName.Text = user.UserName; Nume.Text = user.LastName; Prenume.Text = user.FirstName; Email.Text = user.Email; Asociatie.Checked = user.IsAsoc == true; Locked.Checked = user.IsLockedOut; var farmManager = new FarmManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString); CodUser.DataSource = farmManager.GetAllFarmsForDropDown(); CodUser.DataTextField = "Nume"; CodUser.DataValueField = "Cod"; CodUser.DataBind(); } }