コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                trainee = tbll.GetTraineeById(Convert.ToInt32(Request.QueryString["TraineeID"]));

                WorkoutBLL wbll = new WorkoutBLL(ConfigurationManager.ConnectionStrings["MySwoleMateConnectionString"].ToString());

                List <WorkoutViewModel> workoutList = wbll.GetAllWorkouts();

                List <ListItem> items = new List <ListItem>();

                items.Add(new ListItem("--  Select an option  --", null));

                workoutList.ForEach(delegate(WorkoutViewModel workout)
                {
                    items.Add(new ListItem(
                                  workout.DisplayExercise1
                                  + " " + workout.DisplayExercise2
                                  + " " + workout.DisplayExercise3
                                  + " " + workout.DisplayExercise4
                                  + " " + workout.DisplayExercise5, workout.WorkoutID.ToString()));
                });

                if (trainee.WorkoutID != 0)
                {
                    WorkoutDropdownList.SelectedValue = trainee.WorkoutID.ToString();
                }

                WorkoutDropdownList.DataSource     = items;
                WorkoutDropdownList.DataValueField = "Value";
                WorkoutDropdownList.DataTextField  = "Text";
                WorkoutDropdownList.DataBind();
            }
        }
コード例 #2
0
        private void BindData()
        {
            WorkoutBLL workout = new WorkoutBLL(connectionString);

            WorkoutList.DataSource = workout.GetAllWorkouts();
            WorkoutList.DataBind();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TraineeViewModel trainee = trainee_BLL.GetTraineeById(Convert.ToInt32(Request.QueryString["TraineeID"]));
                TraineeNameLabel.Text = trainee.FirstName + " " + trainee.LastName;

                ddlWorkouts.DataSource     = workout_BLL.GetAllWorkouts();
                ddlWorkouts.DataTextField  = "WorkoutName";
                ddlWorkouts.DataValueField = "WorkoutID";       // not sure if I need this line
                ddlWorkouts.DataBind();
            }
        }
コード例 #4
0
        private void BindData()
        {
            // Store and Display Trainee's Name
            TraineeViewModel trainee = traineeBLL.GetTraineeById(Convert.ToInt32(Request.QueryString["TraineeID"]));

            TraineeName.Text = (trainee.FirstName + " " + trainee.LastName).ToUpper();

            // Retrieve all workouts
            List <WorkoutViewModel> workouts = workoutBLL.GetAllWorkouts();

            WorkoutDropList.DataSource = workouts;
            WorkoutDropList.DataBind();
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //using GetTraineeById method to get the Trainee from the database, which we use to
                //populate the data into the form.
                TraineeViewModel trainee = tbll.GetTraineeById(Convert.ToInt32(Request.QueryString["TraineeID"]));
                FullName.Text = trainee.FirstName + " " + trainee.LastName;

                WorkoutBLL wbll = new WorkoutBLL(ConfigurationManager.ConnectionStrings["MySwoleMateConnectionString"].ToString());
                List <WorkoutViewModel> workouts = wbll.GetAllWorkouts();

                WorkoutList.DataSource     = workouts;
                WorkoutList.DataTextField  = "WorkoutName";
                WorkoutList.DataValueField = "WorkoutID";
                WorkoutList.DataBind();
                WorkoutList.Items.Insert(0, "--Select an option--");
            }
        }