//public void SetCourseId(string courseId)
        //{
        //    hidCourseId.Value = courseId;
        //}

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    var now          = DateTime.Now;
                    var subjectClass = new Academic.DbEntities.Class.SubjectClass()
                    {
                        Id = SubjectSessionId
                        ,
                        Name = txtName.Text
                        ,
                        CreatedDate = now
                        ,
                        IsRegular = false
                        ,
                        SubjectId = CourseId
                        ,
                        EnrollmentMethod = (byte)(ddlEnrollmentMethod.SelectedIndex + 1)
                    };

                    try
                    {
                        subjectClass.StartDate = Convert.ToDateTime(txtStart.Text);
                    }
                    catch
                    {
                        valiStartDate.IsValid = false;
                    }
                    try
                    {
                        subjectClass.EndDate = Convert.ToDateTime(txtEnd.Text);
                    }
                    catch
                    {
                        valiEndDate.IsValid = false;
                    }
                    try
                    {
                        subjectClass.JoinLastDate = Convert.ToDateTime(txtLastEnrollDate.Text);
                    }
                    catch
                    {
                        valiLastEnrollDate.IsValid = false;
                    }


                    if (ddlGroupingOfStudents.SelectedIndex == 0)
                    {
                        subjectClass.HasGrouping = false;
                    }

                    if (Page.IsValid)
                    {
                        using (var helper = new DbHelper.Classes())
                        {
                            var saved = helper.AddOrUpdateSubjectSession(subjectClass);
                            if (saved)
                            {
                                Response.Redirect("~/Views/Course/CourseDetail.aspx?cId=" + CourseId);
                            }
                            else
                            {
                                lblErrorMsg.Visible = true;
                            }
                        }
                    }
                }
                catch { }
            }
        }