protected void editLevels_Click(object sender, EventArgs e) { //overall edit levels Button btn = (Button)sender; string classID = btn.CommandArgument.Split('-')[0].Trim(); Session["currClassID"] = classID; SqlConnection con = new SqlConnection(connString); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Levels WHERE ClassID = @id AND LevelNumber > -1", con); cmd.Parameters.AddWithValue("@id", classID); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); EditDataList.DataSource = dt; EditDataList.DataBind(); con.Close(); EditClassLevels.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { id = Convert.ToInt32(Session["ProfessorID"]); if (Session["LOGGED"] == null) { Session.Clear(); Session["LOGGED"] = "Invalid"; Response.Redirect("index.aspx"); } if (Convert.ToBoolean(Session["Opened"]) == true) { if (Convert.ToBoolean(Session["DeletedVid"]) == true) { Session["DeletedVid"] = null; Response.Write("<script type='text/javascript'>alert('Level has been deleted!');</script>"); } int classID = Convert.ToInt32(Session["currClassID"]); EditDataList.DataSource = null; EditDataList.DataBind(); SqlConnection con = new SqlConnection(connString); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Levels WHERE ClassID = @id AND LevelNumber > -1", con); cmd.Parameters.AddWithValue("@id", classID); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); EditDataList.DataSource = dt; EditDataList.DataBind(); con.Close(); EditClassLevels.Visible = true; ViewClassPanel.Visible = false; CreateClassPanel.Visible = false; ProgressPanel.Visible = false; Bind_DataList(); } else if (!Page.IsPostBack) { if (Convert.ToBoolean(Session["Opened"]) == false) { Response.Write("<script type='text/javascript'>alert('Successful Login!');</script>"); } ViewClassPanel.Visible = false; CreateClassPanel.Visible = false; ProgressPanel.Visible = false; EditClassLevels.Visible = false; Bind_DataList(); } }