public void fvBook_InsertItem() { Book item = new Book(); TryUpdateModel(item); if (ModelState.IsValid) { BooksInventoryEntities _db = new BooksInventoryEntities(); _db.Books.Add(item); _db.SaveChanges(); Response.Redirect("/ViewBooks.aspx"); } }
// The return type can be changed to IEnumerable, however to support // paging and sorting, the following parameters must be added: // int maximumRows // int startRowIndex // out int totalRowCount // string sortByExpression public IQueryable gvBooks_GetData() { BooksInventoryEntities _db = new BooksInventoryEntities(); return(_db.Books); }