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(); }
private void AddNewRowToProgram() { int rowIndex = 0; if (ViewState["CurrentTableProgram"] != null) { //create new datatable, cast datatable of viewstate DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableProgram"]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the values DropDownList programList = (DropDownList)Program_GridView.Rows[rowIndex].Cells[1].FindControl("ProgramList"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["RowNumberProgram"] = i + 1; dtCurrentTable.Rows[i - 1]["Column1Program"] = programList.Text; rowIndex++; } dtCurrentTable.Rows.Add(drCurrentRow); ViewState["CurrentTableProgram"] = dtCurrentTable; Program_GridView.DataSource = dtCurrentTable; Program_GridView.DataBind(); } } else { Response.Write("ViewState is null"); } //Set Previous Data on Postbacks SetPreviousProgramData(); }
//---------------------------------------// //---------PROGRAM GRIDVIEW CODE---------// private void SetInitialProgram() { //Create DataTable DataTable dt = new DataTable(); DataRow dr = null; //Add initail values to DataTable dt.Columns.Add(new DataColumn("RowNumberProgram", typeof(string))); dt.Columns.Add(new DataColumn("Column1Program", typeof(string))); dr = dt.NewRow(); dr["RowNumberProgram"] = 1; dr["Column1Program"] = string.Empty; dt.Rows.Add(dr); dr = dt.NewRow(); //Store the DataTable in ViewState ViewState["CurrentTableProgram"] = dt; Program_GridView.DataSource = dt; Program_GridView.DataBind(); }
protected void DiplomaRemove_Click(object sender, EventArgs e) { if (ViewState["CurrentTableProgram"] != null) { //create new datatable, cast datatable of viewstate DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableProgram"]; DataRow drCurrentRow = null; int rowIndex = 0; if (dtCurrentTable.Rows.Count > 1) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the values DropDownList programList = (DropDownList)Program_GridView.Rows[rowIndex].Cells[1].FindControl("ProgramList"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["RowNumberProgram"] = i; dtCurrentTable.Rows[i - 1]["Column1Program"] = programList.Text; rowIndex++; } dtCurrentTable.Rows[rowIndex - 1].Delete(); ViewState["CurrentTableProgram"] = dtCurrentTable; Program_GridView.DataSource = dtCurrentTable; Program_GridView.DataBind(); SetPreviousProgramData(); } } }