protected void GrdCourse_OnSorting(object sender, GridViewSortEventArgs e)
 {
     //Sorting GridView based on column user selects
     _courseTable.DefaultView.Sort = e.SortExpression;
     GrdCourse.DataSource          = _courseTable;
     GrdCourse.DataBind();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     //Pulling all data from course table and putting it in a DataTable
     _courseTable = _courseDao.PullData();
     if (!IsPostBack)
     {
         //Setting GridView data based off of DataTable
         GrdCourse.DataSource = _courseTable;
         GrdCourse.DataBind();
         ValidateRegistrations();
     }
 }
        protected void BtnResetFilter_OnClick(object sender, EventArgs e)
        {
            //Resetting the GridView to its default view
            _courseTable         = _courseDao.PullData();
            GrdCourse.DataSource = _courseTable;
            GrdCourse.DataBind();

            //Resetting filter boxes
            TxtFilterDate.Text    = "";
            TxtFilterFee.Text     = "";
            TxtFilterSubject.Text = "";

            //Calling method so user cannot register twice for the same course
            ValidateRegistrations();
        }
        protected void BtnFilter_OnClick(object sender, EventArgs e)
        {
            //Declaring variables needed
            var subject = TxtFilterSubject.Text;
            var date    = TxtFilterDate.Text;
            var fee     = TxtFilterFee.Text;

            //Filtering the GridView based on the combination of TextBoxes that were typed into
            if (!subject.Equals("") && date.Equals("") && fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"Subject like '%{subject}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (subject.Equals("") && !date.Equals("") && fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([StartDate], System.String) like '%{date}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (subject.Equals("") && date.Equals("") && !fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([Fee], System.String) like '%{fee}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (!subject.Equals("") && !date.Equals("") && fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([StartDate], System.String) like '%{date}%' and Subject like '%{subject}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (!subject.Equals("") && date.Equals("") && !fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([Fee], System.String) like '%{fee}%' and Subject like '%{subject}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (subject.Equals("") && !date.Equals("") && !fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([StartDate], System.String) like '%{date}%' and CONVERT([Fee], System.String) like '%{fee}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else if (!subject.Equals("") && !date.Equals("") && !fee.Equals(""))
            {
                _courseTable.DefaultView.RowFilter = $"CONVERT([StartDate], System.String) like '%{date}%' and CONVERT([Fee], System.String) like '%{fee}%' and  Subject like '%{subject}%'";
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
            else
            {
                GrdCourse.DataSource = _courseTable;
                GrdCourse.DataBind();
                ValidateRegistrations();
            }
        }