protected void RBSubmit_Click(object sender, EventArgs e) { int count = 0; int countStopper = 0; string StudentID = ""; string SubjectID = ""; string SubjectName = ""; AbcDAL MyDAL = new AbcDAL(""); DataTable ResultTable = MyDAL.PopulateClass(); DataTable ResultTableSubject = MyDAL.SelectSubjectMasterByID(RCBSubject.SelectedValue.ToString().Trim()); foreach (DataRow row in ResultTable.Rows) { SubjectName = ResultTableSubject.Rows[0]["SubjectName"].ToString().Trim(); SubjectID = ResultTable.Rows[count]["SubjectID"].ToString().Trim(); StudentID = ResultTable.Rows[count]["StudentID"].ToString().Trim(); if (StudentID == RCBStudent.SelectedValue.ToString().Trim() && SubjectID == RCBSubject.SelectedValue.ToString().Trim()) { countStopper++; } count++; } if (countStopper >= 1) { Response.Redirect("EnrollSubject.aspx?MsgPos=5&MsgType=warning&MsgContent=Student already exists in " + SubjectName.Trim()); } else { MyDAL.AddClassMaster("Classs A", RCBSubject.SelectedValue, RCBStudent.SelectedValue); Response.Redirect("EnrollSubject.aspx?MsgPos=5&MsgType=warning&MsgContent=Success in Enrollment"); } }
protected void RGClassMaster_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { AbcDAL MyDAL = new AbcDAL(""); RGClassMaster.DataSource = MyDAL.PopulateClass(); }