public ActionResult Insertdetails(Mysite ms) { using (var dbctx = new MVCEntities()) { dbctx.tbl_site.Add(new tbl_site { username = ms.username, city = ms.city, state = ms.state, country = ms.country }); dbctx.SaveChanges(); } return(RedirectToAction("DisplayAll")); }
public ActionResult Display() { List <string> dd; using (var dbctx = new MVCEntities()) { dd = new List <string>(); var res = dbctx.tbl_site.Select(o => o.username); foreach (string item in res) { dd.Add(item); } } Mysite ms = new Mysite { usernames = new SelectList(dd) }; return(View(ms)); }