public IQueryable<Product> GridViewProducts_GetData() { NORTHWNDEntities context = new NORTHWNDEntities(); return context.Products. Include("Supplier").Include("Category"). OrderBy(p => p.ProductID); }
public void GridViewProducts_UpdateItem(int productID) { NORTHWNDEntities context = new NORTHWNDEntities(); Product product = context.Products.Find(productID); if (product == null) { // The item wasn't found ModelState.AddModelError("", String.Format("Product with id {0} was not found", productID)); return; } TryUpdateModel(product); if (ModelState.IsValid) { context.Entry(product).State = EntityState.Modified; context.SaveChanges(); } }