public ActionResult Index() { using (KecamatanDAL service = new KecamatanDAL()) { var kec = service.GetData().ToList(); return(View(kec)); } }
public ActionResult Create() { var lstKec = new List <SelectListItem>(); using (KecamatanDAL svKec = new KecamatanDAL()) { foreach (var kec in svKec.GetData()) { lstKec.Add(new SelectListItem { Value = kec.id_kec.ToString(), Text = kec.nama_kec }); } ViewBag.Kecamatan = lstKec; } return(View()); }