protected void gvExamList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Exm exam = e.Row.DataItem as Exm; Literal litExamId = e.Row.FindControl("litExamId") as Literal; Literal litDate = e.Row.FindControl("litDate") as Literal; HtmlAnchor btnPreviewQuestions = e.Row.FindControl("btnPreviewQuestions") as HtmlAnchor; HtmlAnchor btnViewSubmissions = e.Row.FindControl("btnViewSubmissions") as HtmlAnchor; litExamId.Text = exam.ID.ToString(); litDate.Text = exam.CreatedDate.ToString(); btnPreviewQuestions.HRef = string.Format("{0}?ExamId={1}", URLDefs.PreviewExam, exam.ID); btnViewSubmissions.HRef = string.Format("{0}?ExamId={1}", URLDefs.Submissions, exam.ID); } }
public static List <Exm> GetAllExams() { List <Exm> exams = new List <Objects.Exam>(); using (SqlConnection con = new SqlConnection(DBConnection.ConnectionString)) { using (SqlCommand cmd = new SqlCommand("Proc_Exam_GetAll", con)) { cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Exm exam = Exm.Populate(reader); exams.Add(exam); } } } return(exams); }