List <IdAndName> GetAssignment(DbHelper.ActAndRes helper, string fileName) { var list = new List <IdAndName>(); switch (fileName) { case "AssignmentCheckCreate.aspx": var actId = Request.QueryString["actId"]; var subId = Request.QueryString["SubId"]; var secId = Request.QueryString["secId"]; var ucId = Request.QueryString["ucId"]; var assignment = helper.GetAssignment(Convert.ToInt32(actId)); list.Add(new IdAndName() { Name = assignment.Name, Value = "~/Views/ActivityResource/Assignments/AssignmentView.aspx?SubId=" + subId + "&arId=" + actId + "&secId=" + secId, Void = true, }); using (var clsHelper = new DbHelper.Classes()) { var userClass = clsHelper.GetUserClass(Convert.ToInt32(ucId)); list.Add(new IdAndName() { Name = "Submission from '" + userClass.User.FirstName + "'" }); } break; case "AssignmentCreate.aspx": list.Add(new IdAndName() { Name = "Assignment edit" }); break; case "AssignmentView.aspx": var assId = Request.QueryString["arId"]; var ass = helper.GetAssignment(Convert.ToInt32(assId)); list.Add(new IdAndName() { Name = ass.Name, }); break; case "SubmitAssignmentCreate.aspx": var arId = Request.QueryString["arId"]; var sub = Request.QueryString["SubId"]; var sec = Request.QueryString["secId"]; var assign = helper.GetAssignment(Convert.ToInt32(arId)); list.Add(new IdAndName() { Name = assign.Name, Value = "~/Views/ActivityResource/Assignments/AssignmentView.aspx?SubId=" + sub + "&arId=" + arId + "&secId=" + sec, Void = true, }); if (fileName == "SubmitAssignmentCreate.aspx") { list.Add(new IdAndName() { Name = "Submission" }); } break; } return(list); }
public void LoadCourses() { var date = DateTime.Now; var count = 0; using (var aHelper = new DbHelper.ActAndRes()) using (var helper = new DbHelper.Subject()) using (var clsHelper = new DbHelper.Classes()) { try { //aHelper.ListActivitiesAndResourcesOfSection() var fromDashboard = FromDashboard; var user = Page.User as CustomPrincipal; if (user != null) { //var subjects = helper.GetCurrentRegularSubjectsOfUser(user.Id); //var subjectsArray = helper.ListCurrentAndEarlierCoursesOfUser(user.Id); List <Academic.DbEntities.Subjects.Subject> subjectsArray; bool earlier = false; if (hidLoadType.Value == "earlier") { earlier = true; var subArray = helper.GetEarlierAndCurrentCourseAndClassesForManagerAndTeacherV3(user.Id, false); subjectsArray = subArray[1];//.Keys.ToList(); //subjectsArray = helper.ListEarlierSubjectClasses(user.Id) // .Select(x => (x.IsRegular) ? x.SubjectStructure.Subject : x.Subject).ToList(); } else { var subArray = helper.GetEarlierAndCurrentCourseAndClassesForManagerAndTeacherV3(user.Id, true); subjectsArray = subArray[0];//.Keys.ToList(); //subjectsArray = helper.ListCurrentSubjectClasses(user.Id) // .Select(x => (x.IsRegular) ? x.SubjectStructure.Subject : x.Subject).ToList(); } //foreach (var c in subjects[loadType]) //foreach (var c in subjectsArray[loadType]) foreach (var c in subjectsArray.Distinct()) { //if (!lblHeading.Visible && fromDashboard) //{ // lblHeading.Visible = true; //} CourseUc uc = (CourseUc)Page.LoadControl("~/ViewsSite/DashBoard/Student/CourseOverView/CourseUc.ascx"); var navigationUrl = "~/Views/Course/Section/?SubId=" + c.Id; uc.TitleNavigationTarget = navigationUrl; uc.Id = c.FullName + "_" + c.Id; uc.Title = c.FullName; //classes calculation var userclasses = clsHelper.GetCurrentUserClassesOfUser(c.Id, user.Id); //var clsIds = classes.Select(x => x.SubjectClass.Id).ToList(); var roles = user.GetRoles(); var elligible = false; //Context.UserClass.Any(x=>x.subje) // var roles = user.GetRoles().Select(x => x.Role.RoleName).ToList(); //if () { elligible = user.IsElligibleForManagement; //roles.Contains(DbHelper.StaticValues.Roles.CourseEditor.ToString()) // || roles.Contains(DbHelper.StaticValues.Roles.Manager.ToString()) // || roles.Contains(DbHelper.StaticValues.Roles.Admin.ToString()) // || roles.Contains("teacher"); } var enterSubject = false; //Messages //Restriction calculation is not done yet if (!earlier) { foreach (var sec in c.SubjectSections.AsEnumerable().Where(x => !(x.Void ?? false))) { var canView = elligible; if (!canView) { canView = aHelper.EvaluateRestriction(null, sec.Restriction, user.Id); } if (canView) // { foreach (var act in sec.ActivityResources.AsEnumerable() .Where(x => x.ActivityOrResource && !(x.Void ?? false)))//only activity { if (!elligible) { canView = aHelper.EvaluateRestriction(null, act.Restriction, user.Id); } if (canView) // { foreach (var ac in act.ActivityClasses) { //ac.ActivityResourceViews.Where(x=>x.) var usrCls = userclasses.FirstOrDefault(x => x.SubjectClassId == ac.SubjectClassId); if (usrCls != null) { //check for activity view var viewed = ac.ActivityResourceViews.FirstOrDefault(a => a.UserClassId == usrCls.Id); //!cls.ActivityResourceViews.ToList().Exists(x => x.UserClassId == classMatch.Id) if (!(user.IsInRole("manager") || user.IsInRole("teacher"))) { if (viewed != null) { if ((date - viewed.ViewedDate).TotalDays < 1) { enterSubject = true; var cuc = (CourseMessageUC) Page.LoadControl("~/ViewsSite/DashBoard/Student/CourseOverView/CourseMessageUC.ascx"); var thisIcon = ActivityResourceValues.RetriveMethod(actOrRes: true, actResType: (byte)(act.ActivityResourceType)); if (thisIcon != null) { cuc.ImageLink = thisIcon.IconPath; cuc.Text = @"You have new """ + (thisIcon.Name) + @""""; cuc.NavigateUrl = navigationUrl + "#section_" + sec.Id; cuc.ToolTip = act.Name; uc.AddMessages(cuc); //if (fromDashboard) //{ // if (!pnlCourseList.Visible) // { // pnlCourseList.Visible = true; // } //} } break; } } else //(!ac.ActivityResourceViews.ToList().Exists(x => x.UserClassId == usrCls.Id))// && x.ActivityClassId == ac.Id) { //then don't display enterSubject = true; var cuc = (CourseMessageUC) Page.LoadControl("~/ViewsSite/DashBoard/Student/CourseOverView/CourseMessageUC.ascx"); //var thisType = Enum.GetNames(typeof(Enums.Activities))[act.ActivityResourceType-1]; var thisIcon = ActivityResourceValues.RetriveMethod(actOrRes: true, actResType: (byte)(act.ActivityResourceType)); if (thisIcon != null) { cuc.ImageLink = thisIcon.IconPath; cuc.Text = "You have new \"" + (thisIcon.Name) + "\""; //cuc.NavigateUrl = thisIcon.ViewUrl // + "?SubId=" + c.Id + // "&arId=" + act.ActivityResourceId + // "&secId=" + sec.Id + // "&edit=0"; cuc.NavigateUrl = navigationUrl + "#section_" + sec.Id; cuc.ToolTip = act.Name; uc.AddMessages(cuc); } break; } } #region Submission //var actres = ahelper.GetActivityResource(true // , (byte)(Enums.Activities.Assignment + 1), AssignmentId); if (usrCls.Role.RoleName == "teacher" || usrCls.Role.RoleName == "manager") { if (act.ActivityOrResource && act.ActivityResourceType == (byte)(Enums.Activities.Assignment + 1) && !(act.Void ?? false)) { //then its assignment .. check for new submission var ass = aHelper.GetAssignment(act.ActivityResourceId); if (ass != null) { //its definitely assignment var users = ass.Submissions.Count; //.OrderByDescending(x => x.SubmittedDate).Select(x => x.UserClassId).ToList(); var gradings = act.ActivityGradings.Count; //.Select(x=>x.UserClassId).ToList(); //var anyUnGraded = act.ActivityGradings.Any(x => // !users.Contains(x.UserClassId)); if (users > gradings) { enterSubject = true; var cuc = (CourseMessageUC)Page.LoadControl ("~/ViewsSite/DashBoard/Student/CourseOverView/CourseMessageUC.ascx"); var thisIcon = ActivityResourceValues.AssignmentActivity(); //ActivityResourceValues.RetriveMethod(actOrRes: true, actResType: (byte)(act.ActivityResourceType)); if (thisIcon != null) { cuc.ImageLink = "~/Content/Icons/ActivityResource/Assignment/document_submit_icon.png"; //thisIcon.IconPath; cuc.Text = "You have new Submission"; //+ (thisIcon.Name); cuc.NavigateUrl = navigationUrl + "#section_" + sec.Id; cuc.ToolTip = act.Name; uc.AddMessages(cuc); } break; } } } } #endregion } } } } } //Messages list } } if (!fromDashboard) { this.pnlCourseList.Controls.Add(uc); count++; } else { if (enterSubject) { if (!lblHeading.Visible) { lblHeading.Visible = fromDashboard; } this.pnlCourseList.Controls.Add(uc); count++; } } } } } catch (Exception e) { } } this.Visible = count != 0; }
private void LoadAssignment() { using (var helper = new DbHelper.ActAndRes()) { var ass = helper.GetAssignment(AssignmentId); if (ass != null) { RestrictionUC.SetActivityResource(true, ((int)Enums.Activities.Assignment) + 1, ass.Id); var actRes = helper.GetActivityResource(true, ((int)Enums.Activities.Assignment) + 1, ass.Id); if (actRes != null) { var classes = new List <IdAndName>(); foreach (var cls in actRes.ActivityClasses.AsEnumerable()) { classes.Add(new IdAndName() { Id = cls.SubjectClassId , Name = cls.SubjectClass.IsRegular ? cls.SubjectClass.GetName : cls.SubjectClass.Name , Void = false }); } txtName.Text = ass.Name; CKEditor1.Text = ass.Description; chkDisplayDesc.Checked = ass.DispalyDescriptionOnPage ?? false; ClassesInActivityChoose1.PopulateClassPanel(classes); GradeInActivityUc1.SetGradeValues(actRes, ass); #region File and online submission if (ass.FileSubmission) { chkFileSubmission.Checked = true; txtMaxFiles.Text = (ass.MaximumNoOfUploadedFiles ?? 0).ToString(); txtMaxSize.Text = (ass.MaximumSubmissionSize ?? 0).ToString(); txtMaxFiles.Enabled = true; txtMaxSize.Enabled = true; } else { chkFileSubmission.Checked = false; txtMaxFiles.Enabled = false; txtMaxSize.Enabled = false; } if (ass.OnlineText) { chkOnlineSubmission.Checked = true; txtWordLimit.Text = ass.WordLimit.ToString(); txtWordLimit.Enabled = true; } else { chkOnlineSubmission.Checked = false; txtWordLimit.Enabled = false; } #endregion #region Date if (ass.CutOffDate != null) { chkCutOff.Checked = true; txtCutOff.Text = ass.CutOffDate.Value.ToShortDateString(); } else { chkCutOff.Checked = false; txtCutOff.Enabled = false; } if (ass.DueDate != null) { chkDue.Checked = true; txtDue.Text = ass.DueDate.Value.ToShortDateString(); txtDue.Enabled = true; } else { chkDue.Checked = false; txtDue.Enabled = false; } if (ass.SubmissionFrom != null) { chkFrom.Checked = true; txtFrom.Text = ass.SubmissionFrom == null ? "" : ass.SubmissionFrom.Value.ToShortDateString(); txtFrom.Enabled = true; } else { chkFrom.Checked = false; txtFrom.Enabled = false; } #endregion //here } } } }
//DbHelper.ActAndRes ahelper, private void PopulateClasses(CustomPrincipal user) { using (var ahelper = new DbHelper.ActAndRes()) { var actres = ahelper.GetActivityResource(true, (byte)(Enums.Activities.Assignment + 1), AssignmentId); if (actres != null) { ahelper.SetActivityResourceView(actres.Id, SubjectId, user.Id); var submitButtonVisiblity = true; var colorChange = false; //Color backColor = Color.White; //Color foreColor = Color.Black; var status = ""; var grade = "N/A"; var remarks = ""; var assignmentId = AssignmentId; #region Restriction and all codes var elligible = false; var roles = user.GetRoles(); if (roles.Contains(DbHelper.StaticValues.Roles.CourseEditor.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Manager.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Admin) || roles.Contains("teacher")) { elligible = true; } var canView = elligible; if (!canView) { canView = ahelper.EvaluateRestriction(null, actres.Restriction, user.Id); } //else // submitButtonVisiblity = false; if (canView) { #region Assignment Load var date = DateTime.Now; var ass = ahelper.GetAssignment(assignmentId); if (ass != null) { var timeRemaining = "N/A"; //actres will be used for restriction n class lblName.Text = ass.Name; lblPageTitle.Text = ass.Name; lblDescription.Text = ass.Description; #region Date and time Calculation if (ass.SubmissionFrom != null) { if (ass.SubmissionFrom > date) { var rem = (ass.SubmissionFrom.Value - date); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " for submission start."; submitButtonVisiblity = false; } } if (ass.DueDate != null) { lblDueDate.Text = ass.DueDate.Value.ToString("f"); if (ass.DueDate < date) { var rem = (date - ass.DueDate.Value); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " elapsed since due date."; //timeRemaining = "Due date finished on " + ass.DueDate.Value.ToString("f"); colorChange = true; //backColor = Color.DeepPink; //foreColor = Color.White; } else { var rem = (ass.DueDate.Value - date); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " for submission end."; } } else { lblDueDate.Text = "N/A"; } if (ass.CutOffDate != null && ass.CutOffDate < date) { timeRemaining = "Sumission period end."; submitButtonVisiblity = false; } lblTimeRemaining.Text = timeRemaining; #endregion #endregion foreach (var c in actres.ActivityClasses) { var userclass = c.SubjectClass.ClassUsers.FirstOrDefault(y => y.UserId == user.Id); if (userclass != null) { #region Each class view initialize var subCls = c.SubjectClass; var classUc = (ClassGradeDisplayUc) Page.LoadControl("~/Views/ActivityResource/Grading/ClassGradeDisplayUc.ascx"); classUc.SetData(subCls.IsRegular ? subCls.GetName : subCls.Name); if (subCls.SessionComplete ?? false) { classUc.Enable = false; } pnlGradeList.Controls.Add(classUc); // pnlGradeList.Controls.Add(new Literal() {Text = "<br />"}); //pnlGradeList.Controls.Add(new Literal() {Text = "<br />"}); #endregion if (userclass.Role.RoleName == "student") { #region submit view display classUc.ShowStudentListTableHeading = false; if (!(subCls.SessionComplete ?? false)) { //disable the submit button var stdGradeUc = (StudentGradeDispalyUc) Page.LoadControl( "~/Views/ActivityResource/Grading/StudentGradeDispalyUc.ascx"); //stdGradeUc.RedirectUrl = "~/Views/ActivityResource/Grading/?actResId=" + actres.Id + // "&SubId=" + SubjectId + // "&secId=" + SectionId; stdGradeUc.RedirectUrl = "~/Views/ActivityResource/Assignments/SubmitAssignmentCreate.aspx?arId=" + AssignmentId + "&SubId=" + SubjectId + "&secId=" + SectionId + "&ucId=" + userclass.Id; stdGradeUc.SubmitButtonVisible = ass.FileSubmission || ass.OnlineText; #region Submissions var subm = ass.Submissions.FirstOrDefault(x => x.UserClass.UserId == user.Id); var submissionEnabled = true; if (subm != null) { status = "Submitted on : " + ((subm.ModifiedDate == null) ? subm.SubmittedDate.ToString("f") : subm.ModifiedDate.Value.ToString("f")); stdGradeUc.SubmitButtonText = "Edit Submission"; var obtgrade = actres.ActivityGradings.FirstOrDefault( x => x.UserClassId == subm.UserClassId); if (obtgrade != null) { if (obtgrade.ObtainedGradeId != null) { grade = obtgrade.ObtainedGrade.Value; } else { grade = (obtgrade.ObtainedGradeMarks ?? 0).ToString("F"); } submissionEnabled = false;//since already graded remarks = obtgrade.Remarks; } } else { status = "Not submitted yet"; } #endregion classUc.AddControlsOusideOfTable(stdGradeUc); stdGradeUc.SubmitButtonVisible = submitButtonVisiblity; if (colorChange) { stdGradeUc.SubmitDueIndicator = true; lblTimeRemaining.ForeColor = Color.Red; //lblTimeRemaining.ForeColor = foreColor; //stdGradeUc.SubmitButtonBackColor = backColor; //stdGradeUc.SubmitButtonForeColor = foreColor; } stdGradeUc.SetData(status, grade, remarks, submissionEnabled, ass.ShowGradeToStudents); } #endregion //ucStdRole.Add(userclass); } else if (userclass.Role.RoleName == "teacher" || userclass.Role.RoleName == "manager") { //grade uc display for that class #region Grading view display , start of teacher role classUc.ShowStudentListTableHeading = true; var any = false; foreach (var clsUser in subCls.ClassUsers.Where(x => !(x.Void ?? false))) { //initialize each user uc if (clsUser.Role.RoleName == "student" && !(clsUser.Void ?? false)) { var userUc = (UserGradeDisplayUc) Page.LoadControl( "~/Views/ActivityResource/Grading/UserGradeDisplayUc.ascx"); userUc.SectionId = SectionId; userUc.SubjectId = SubjectId; userUc.SetData(clsUser, actres.Id, ass.Id, actres.ActivityResourceType); classUc.AddControls(userUc); any = true; } } if (!any) { classUc.AddControlsInsideTable(new Literal() { Text = "<tr>" + "<td>" + "No students found." + "</td>" + "</tr>" }, false); } #endregion of teacher role } } } //foreach end } else { Response.Redirect("~/"); } } else { Response.Redirect("~/"); } #endregion } else { Response.Redirect("~/"); } } }
void LoadActivity(int assignmentId) { using (var helper = new DbHelper.ActAndRes()) { var ass = helper.GetAssignment(assignmentId); if (ass != null) { var submission = ass.Submissions.FirstOrDefault(x => x.UserClassId == UserClassId); if (submission != null) { var files = new List <FileResourceEventArgs>(); SubmissionId = submission.Id; if (ass.OnlineText) { CKEditor1.Text = submission.SubmissionText; } if (ass.FileSubmission) { FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0; var i = 1; foreach (var f in submission.AssignmentSubmissionFiles) { files.Add(new FileResourceEventArgs() { Id = f.UserFileId, Visible = true, FileType = f.UserFile.FileType, IconPath = f.UserFile.IconPath, FilePath = f.UserFile.FileDirectory + "/" + f.UserFile.FileName, FileDisplayName = f.UserFile.DisplayName, FileSizeInBytes = f.UserFile.FileSizeInBytes , LocalId = i.ToString() }); i++; } FilesDisplay1.SetInitialValues(files); } } AssignmentId = assignmentId; lblName.Text = ass.Name; lblDescription.Text = ass.Description; if (ass.FileSubmission || ass.OnlineText) { if (ass.FileSubmission) { pnlFileSubmit.Visible = true; lblFileLimit.Text = "(File Limit : " + (ass.MaximumNoOfUploadedFiles ?? 0) + " files, " + " Maximum size per file: " + (ass.MaximumSubmissionSize ?? 0) + "KB)"; //FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0; } else { pnlFileSubmit.Visible = false; pnlFileSubmit.Controls.Clear(); } if (ass.OnlineText) { //lblScript.Text = WordLimitScript(ass.WordLimit ?? 0); lblWordLimit.Text = "(Word Limit : " + (ass.WordLimit ?? 0) + " words)"; pnlText.Visible = true; } else { pnlText.Visible = false; pnlText.Controls.Clear(); } } else { btnSubmit.Visible = false; } } } }
private void LoadSubmission() { using (var helper = new DbHelper.ActAndRes()) { var userClassId = UserClassId; var actres = helper.GetActivityResource(ActivityResourceId); if (actres != null) { var grd = (actres.ActivityGradings.FirstOrDefault(x => x.UserClassId == userClassId)); var ass = helper.GetAssignment(ActivityId); if (ass != null) { var sub = ass.Submissions.FirstOrDefault(x => x.UserClassId == userClassId); lblName.Text = ass.Name; lblDescription.Text = ass.Description; if (sub != null) { if (ass.FileSubmission) { var files = new List <FileResourceEventArgs>(); FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0; var i = 1; foreach (var f in sub.AssignmentSubmissionFiles) { files.Add(new FileResourceEventArgs() { Id = f.UserFileId, Visible = true, FileType = f.UserFile.FileType, IconPath = f.UserFile.IconPath, FilePath = f.UserFile.FileDirectory + "/" + f.UserFile.FileName, FileDisplayName = f.UserFile.DisplayName, FileSizeInBytes = f.UserFile.FileSizeInBytes , LocalId = i.ToString() }); i++; } FilesDisplay1.SetInitialValues(files); } if (grd != null) { var user = grd.UserClass.User; lblStudentName.Text = user.FirstName + (string.IsNullOrEmpty(user.MiddleName)? "": " " + user.MiddleName) + (string.IsNullOrEmpty(user.LastName) ? "" : " " + user.LastName); lblEmail.Text = user.Email; lblClassName.Text = grd.UserClass.SubjectClass.GetName; var std = user.Student.FirstOrDefault(); if (std != null) { lblRoll.Text = std.CRN; } txtRemarks.Text = grd.Remarks; } else { using (var clsHelper = new DbHelper.Classes()) { var uc = clsHelper.GetUserClass(userClassId); if (uc != null) { var user = uc.User; lblStudentName.Text = user.FirstName + (string.IsNullOrEmpty(user.MiddleName) ? "" : " " + user.MiddleName) + (string.IsNullOrEmpty(user.LastName) ? "" : " " + user.LastName); lblEmail.Text = user.Email; lblClassName.Text = uc.SubjectClass.GetName; var std = user.Student.FirstOrDefault(); if (std != null) { lblRoll.Text = std.CRN; } } else { Response.Redirect("~/Views/All_Resusable_Codes/Error/ErrorPage.aspx"); } } } if (ass.OnlineText) { pnlText.Visible = true; txtSubmittedText.Text = sub.SubmissionText; lblWordLimit.Text = "(Word limit : " + (ass.WordLimit ?? 0) + " words)"; } if (ass.FileSubmission) { pnlFileSubmit.Visible = true; lblFileLimit.Text = "(Maximum No. of files allowed : " + (ass.MaximumNoOfUploadedFiles ?? 0) + ", Maximum file size : " + (ass.MaximumSubmissionSize ?? 0) + "KB)"; //each file load } if (ass.GradeType.RangeOrValue) //value { var values = ass.GradeType.GradeValues.ToList(); ddlGrade.Visible = true; var lst = new List <Academic.DbEntities.Grades.GradeValue>(); var maxid = 0; try { maxid = Convert.ToInt32(ass.MaximumGrade); } catch { } var max = values.FirstOrDefault(x => x.Id == maxid); if (max != null) { lblMaximumGrade.Text = max.Value; foreach (var gv in ass.GradeType.GradeValues) { if ((gv.EquivalentPercentOrPostition ?? 0).CompareTo( (max.EquivalentPercentOrPostition ?? 0)) <= 0) { lst.Add(gv); } } } var minid = 0; try { minid = Convert.ToInt32(ass.GradeToPass); } catch { } var min = values.FirstOrDefault(x => x.Id == minid); if (min != null) { lblMinimumGradeToPass.Text = min.Value; } ddlGrade.DataSource = lst; ddlGrade.DataBind(); if (grd != null) { try { if ((grd.ObtainedGradeId ?? 0) > 0) { ddlGrade.SelectedValue = (grd.ObtainedGradeId ?? 0).ToString(); } } catch { } } } else//range { txtGrade.Visible = true; lblMaximumGrade.Text = ass.MaximumGrade; lblMinimumGradeToPass.Text = ass.GradeToPass; if (grd != null) { txtGrade.Text = (grd.ObtainedGradeMarks ?? 0).ToString("F"); } } } } } } }