protected void ClearFields()
    {
        ProgramName.Text               = "";
        CredentialType.SelectedIndex   = 0;
        ProgramLink.Text               = "";
        ProgramLength.Text             = "";
        ProgramLengthDDL.SelectedIndex = 0;
        WorkOutdoors.Checked           = false;
        ShiftWork.Checked              = false;
        Travel.Checked             = false;
        Activated.Checked          = false;
        CompetitiveAdv.Text        = "";
        EntReqDetail.Text          = "";
        CategoryList.SelectedIndex = 0;
        ShowCoursesView.Checked    = false;
        ShowDipPathView.Checked    = false;
        ShowDegPathView.Checked    = false;

        Course_Gridview.DataBind();
        SetInitialCourse();
        Program_GridView.DataBind();
        SetInitialProgram();
        DegreeList_GridView.DataBind();
        SetInitialDegree();
    }
    //---------COURSE GRIDVIEW CODE----------//
    private void SetInitialCourse()
    {
        //Create DataTable
        DataTable dt = new DataTable();
        DataRow   dr = null;

        //Add initail values to DataTable
        dt.Columns.Add(new DataColumn("RowNumberCourse", typeof(string)));
        dt.Columns.Add(new DataColumn("Column1Course", typeof(string)));
        dt.Columns.Add(new DataColumn("Column2Course", typeof(string)));
        //dt.Columns.Add(new DataColumn("Column3", typeof(string)));

        dr = dt.NewRow();
        dr["RowNumberCourse"] = 1;
        dr["Column1Course"]   = string.Empty;
        dr["Column2Course"]   = string.Empty;
        //dr["Column3"] = string.Empty;

        dt.Rows.Add(dr);
        dr = dt.NewRow();

        //Store the DataTable in ViewState
        ViewState["CurrentTableCourse"] = dt;
        Course_Gridview.DataSource      = dt;
        Course_Gridview.DataBind();
    }
    private void AddNewRowToCourse()
    {
        int rowIndex = 0;

        if (ViewState["CurrentTableCourse"] != null)
        {
            //create new datatable, cast datatable of viewstate
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableCourse"];
            DataRow   drCurrentRow   = null;

            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                {
                    //extract the values
                    DropDownList courseList = (DropDownList)Course_Gridview.Rows[rowIndex].Cells[1].FindControl("CourseList");
                    TextBox      marks      = (TextBox)Course_Gridview.Rows[rowIndex].Cells[2].FindControl("EnterMark");

                    drCurrentRow = dtCurrentTable.NewRow();
                    drCurrentRow["RowNumberCourse"] = i + 1;

                    dtCurrentTable.Rows[i - 1]["Column1Course"] = courseList.Text;
                    dtCurrentTable.Rows[i - 1]["Column2Course"] = marks.Text;

                    rowIndex++;
                }
                dtCurrentTable.Rows.Add(drCurrentRow);
                ViewState["CurrentTableCourse"] = dtCurrentTable;

                Course_Gridview.DataSource = dtCurrentTable;
                Course_Gridview.DataBind();
            }
        }

        else
        {
            Response.Write("ViewState is null");
        }
        //Set Previous Data on Postbacks
        SetPreviousCourseData();
    }
    protected void ButtonSubtract_Click(object sender, EventArgs e)
    {
        if (ViewState["CurrentTableCourse"] != null)
        {
            //create new datatable, cast datatable of viewstate
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableCourse"];
            DataRow   drCurrentRow   = null;

            int rowIndex = 0;

            if (dtCurrentTable.Rows.Count > 1)
            {
                for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                {
                    //extract the values
                    DropDownList courseList = (DropDownList)Course_Gridview.Rows[rowIndex].Cells[1].FindControl("CourseList");
                    TextBox      marks      = (TextBox)Course_Gridview.Rows[rowIndex].Cells[2].FindControl("EnterMark");

                    drCurrentRow = dtCurrentTable.NewRow();
                    drCurrentRow["RowNumberCourse"] = i;

                    dtCurrentTable.Rows[i - 1]["Column1Course"] = courseList.Text;
                    dtCurrentTable.Rows[i - 1]["Column2Course"] = marks.Text;

                    rowIndex++;
                }

                dtCurrentTable.Rows[rowIndex - 1].Delete();

                ViewState["CurrentTableCourse"] = dtCurrentTable;

                Course_Gridview.DataSource = dtCurrentTable;
                Course_Gridview.DataBind();

                SetPreviousCourseData();
            }
        }
    }