protected void StudentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer); int RowIndex = row.RowIndex; SqlConnection objSqlConnection = new SqlConnection( WebConfigurationManager.ConnectionStrings["StudentDataBaseConnection"].ConnectionString); if (e.CommandName == "delete") { var command = String.Format("DELETE FROM Student WHERE StudentId = {0}", StudentGrid.DataKeys[RowIndex].Value); SqlCommand objSqlCommand = new SqlCommand(command, objSqlConnection); objSqlConnection.Open(); objSqlCommand.ExecuteNonQuery(); objSqlConnection.Close(); e.Handled = true; StudentGrid.DataSource = ShowListOfStudents(); StudentGrid.DataBind(); } else if (e.CommandName == "schedule") { Session["StudentId"] = StudentGrid.DataKeys[RowIndex].Value; Session["StudentName"] = StudentGrid.DataKeys[RowIndex].Value; Response.Redirect(@"\Admin\AddSchedule.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StudentGrid.DataSource = ShowListOfStudents(); StudentGrid.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StudentNameLabel.Text = Session["StudentName"]?.ToString(); StudentGrid.DataSource = GetStudentInfo(); StudentGrid.DataBind(); } }
protected void AddBtn_Click(object sender, EventArgs e) { List <string> listOfSubjects = new List <string>(); foreach (ListItem listItem in ListBoxSubjects.Items) { if (listItem.Selected) { listOfSubjects.Add(listItem.Value); } } InsertSubjects(listOfSubjects); StudentGrid.DataSource = GetStudentInfo(); StudentGrid.DataBind(); }
protected void AddBtn_Click(object sender, EventArgs e) { var studentId = Convert.ToInt32(Session["StudentId"]); List <string> listOfSubjects = new List <string>(); foreach (ListItem listItem in ListBoxSubjects.Items) { if (listItem.Selected) { listOfSubjects.Add(listItem.Value); } } studentService.InsertListOfSubjects(listOfSubjects, studentId); StudentGrid.DataSource = GetStudentInfo(); StudentGrid.DataBind(); }
protected void StudentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer); int RowIndex = row.RowIndex; if (e.CommandName == "delete") { var StudentId = StudentGrid.DataKeys[RowIndex].Value; studentService.DeleteStudent(StudentId); e.Handled = true; StudentGrid.DataSource = ShowListOfStudents(); StudentGrid.DataBind(); } else if (e.CommandName == "schedule") { Session["StudentId"] = StudentGrid.DataKeys[RowIndex].Values[0]; Session["StudentName"] = StudentGrid.DataKeys[RowIndex].Values[1]; Response.Redirect(@"\Admin\AddSchedule.aspx"); } }
protected void Submit_Score(object sender, EventArgs e) { var courseId = Convert.ToInt32(Session["CourseId"]); var studentId = Convert.ToInt32(Session["StudentId"]); string attendence = Attendence.Text; string Quiz = quiz.Text; string homeWork = HomeWork.Text; string research = Reasearch.Text; string labPractice = LabPractice.Text; string finalExam = FinalExam.Text; studentService.SubmitScore(courseId, studentId, attendence, Quiz, homeWork, research, labPractice, finalExam); StudentGrid.DataSource = GetStudentInfo(); StudentGrid.DataBind(); SubjectLbl.Visible = false; scorediv.Visible = false; Attendence.Text = "0"; quiz.Text = "0"; HomeWork.Text = "0"; Reasearch.Text = "0"; LabPractice.Text = "0"; FinalExam.Text = "0"; }
protected void StudentsGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlConnection myconnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["smsconnection"].ConnectionString); string id = StudentsGrid.DataKeys[e.RowIndex].Values["StudentId"].ToString(); myconnect.Open(); try { SqlCommand mycommand = new SqlCommand("getstudent", myconnect); mycommand.Parameters.AddWithValue("@StudentId", id); mycommand.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader myreader = mycommand.ExecuteReader(); StudentGrid.DataSource = myreader; StudentGrid.DataBind(); } catch (Exception ex) { throw ex; } finally { myconnect.Close(); } }