public ActionResult PathologyTest() { List <Pathology> PathologyList = new List <Pathology>(); Property p = new Property(); DataSet ds = new DataSet(); p.OnTable = "FetchPathologyTest"; ds = dl.FetchPathologyTest_sp(p); List <SelectListItem> CategoryList = new List <SelectListItem>(); CategoryList.Add(new SelectListItem { Text = "Select Category", Value = "" }); foreach (DataRow dr in ds.Tables[1].Rows) { CategoryList.Add(new SelectListItem { Text = dr["CategoryName"].ToString(), Value = dr["CategoryId"].ToString() }); } ViewBag.CategoryList = new SelectList(CategoryList, "Value", "Text"); List <SelectListItem> PatientList = new List <SelectListItem>(); PatientList.Add(new SelectListItem { Text = "Select Patient", Value = "" }); foreach (DataRow dr in ds.Tables[2].Rows) { PatientList.Add(new SelectListItem { Text = dr["Name"].ToString(), Value = dr["PatientId"].ToString() }); } ViewBag.PatientList = new SelectList(PatientList, "Value", "Text"); List <SelectListItem> DoctorList = new List <SelectListItem>(); DoctorList.Add(new SelectListItem { Text = "Select Doctor", Value = "" }); foreach (DataRow dr in ds.Tables[3].Rows) { DoctorList.Add(new SelectListItem { Text = dr["FullName"].ToString(), Value = dr["EmployeeId"].ToString() }); } ViewBag.DoctorList = new SelectList(DoctorList, "Value", "Text"); try { foreach (DataRow item in ds.Tables[0].Rows) { Pathology m = new Pathology(); m.PathologyId = item["PathologyId"].ToString(); m.TestName = item["TestName"].ToString(); m.ShortName = item["ShortName"].ToString(); m.TestType = item["TestType"].ToString(); m.SubCategoryId = item["SubCategoryId"].ToString(); m.CategoryId = item["CategoryId"].ToString(); m.CategoryName = item["CategoryName"].ToString(); m.SubCategoryName = item["SubCategoryName"].ToString(); m.Method = item["Method"].ToString(); m.ReportDays = item["ReportDays"].ToString(); m.Charge = item["Charge"].ToString(); m.IsActive = item["IsActive"].ToString(); PathologyList.Add(m); } ViewBag.PathologyList = PathologyList; } catch (Exception e) { } return(View()); }