// This is the Insert method to insert the entered Person item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new WebApplication3.Models.Person();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.People.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }
Exemple #2
0
        // This is the Insert method to insert the entered Person item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new WebApplication3.Models.Person();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.People.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }