//Add Subject public void addSubject() { try { OptionalSubjectsBLL opSubject = new OptionalSubjectsBLL(); OptionalSubjects ODal = new OptionalSubjects(); ODal.classID = Convert.ToInt64(ddlClasses.SelectedValue); ODal.optionalSubjectName = txtOpSubject.Text; ODal.current_Session = Session["Current_Session"].ToString(); string message = opSubject.addOptionalSubject(ODal); if (message.Contains("Sucessfully")) { lblSuccess.Text = message; lblError.Visible = false; lblSuccess.Visible = true; txtOpSubject.Text = ""; txtOpSubject.Focus(); } else { lblError.Text = message; lblError.Visible = true; lblSuccess.Visible = false; } } catch (Exception ex) { lblError.Text = ex.ToString(); lblError.Visible = true; lblSuccess.Visible = false; } }
//Populate Grid public void getAllSubjects() { OptionalSubjectsBLL opSubject = new OptionalSubjectsBLL(); long id = Convert.ToInt64(ddlClasses.SelectedValue); List <OptionalSubjects> opSubList = opSubject.getAllOptionalSubjects(id); if (opSubList.Count > 0) { gvOptionalSubjects.DataSource = opSubList; gvOptionalSubjects.DataBind(); lblError.Visible = false; lblSuccess.Visible = false; lblSuccess.Text = ""; } else { gvOptionalSubjects.DataSource = null; gvOptionalSubjects.DataBind(); lblSuccess.Text = ""; lblError.Visible = true; lblError.Text = "No Subjects Found"; } }