Пример #1
0
        private void BindData()
        {
            WorkoutBLL workout = new WorkoutBLL(connectionString);

            WorkoutList.DataSource = workout.GetAllWorkouts();
            WorkoutList.DataBind();
        }
        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--");
            }
        }