public void PopulateExam() { var userId = HttpContext.Current.User.Identity.GetUserId(); var school = DropDownManager.GetSchoolByUserId(userId); if (school != null) { lblSchoolId.Text = school.Id.ToString(); lblSchoolType.Text = school.SchoolTypeId.ToString(); lblSchoolCat.Text = school.CategoryId.ToString(); string catId = school.CategoryId.ToString(); var dt = new DataTable(); dt.Columns.Add("SN"); dt.Columns.Add("ID"); dt.Columns.Add("EXAM"); dt.Columns.Add("EXAMCODE"); dt.Columns.Add("FEE"); var Exams = DropDownManager.GetExaminations(catId); int sn = 0; foreach (var item in Exams) { string examId = item.ExamId.ToString(); string examName = item.Name.ToString(); string examCode = item.ExamCode.ToString(); string examFee = item.Fee.ToString(); string examStatus = item.Activated.ToString(); sn++; dt.Rows.Add(sn, examId, examName, examCode, examFee); } gvExam.DataSource = dt; gvExam.DataBind(); } }