public ActionResult Prescription() { List <Prescription> CategoryList = new List <Prescription>(); Property p = new Property(); DataSet ds = new DataSet(); p.OnTable = "FetchPrescription"; ds = dl.FetchPrescription_sp(p); List <SelectListItem> Categoryinventory = new List <SelectListItem>(); Categoryinventory.Add(new SelectListItem { Text = "Select", Value = "" }); foreach (DataRow dr in ds.Tables[1].Rows) { Categoryinventory.Add(new SelectListItem { Text = dr["CategoryName"].ToString(), Value = dr["CategoryId"].ToString() }); } ViewBag.Categoryinventory = new SelectList(Categoryinventory, "Value", "Text"); try { foreach (DataRow item in ds.Tables[0].Rows) { Prescription m = new Prescription(); m.PId = item["PId"].ToString(); m.PatientId = item["PatientId"].ToString(); m.IPDId = item["IPDId"].ToString(); m.CategoryId = item["CategoryId"].ToString(); m.CategoryName = item["CategoryName"].ToString(); m.Header = item["Header"].ToString(); m.Footer = item["Footer"].ToString(); m.Medicine = item["Medicine"].ToString(); m.Dosage = item["Dosage"].ToString(); m.Instruction = item["Instruction"].ToString(); m.PrescriptionNo = item["PrescriptionNo"].ToString(); m.Date = item["Date"].ToString(); CategoryList.Add(m); } ViewBag.CategoryList = CategoryList; } catch (Exception e) { } return(View()); }