public ActionResult ProductsGridViewPartialUpdate(AdvancedMasterDetail.Models.Product item, int key)
        {
            var model = context.Products;

            ViewData["productKey"] = key;
            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.ProductID == item.ProductID);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        context.SubmitChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var querymodel = context.Products.Where(it => it.SupplierID == key);

            return(PartialView("_ProductsGridViewPartial", querymodel));
        }
        public ActionResult ProductsGridViewPartialAddNew(AdvancedMasterDetail.Models.Product item, int key)
        {
            var model = context.Products;

            ViewData["productKey"] = key;
            if (ModelState.IsValid)
            {
                try
                {
                    item.SupplierID = key;
                    item.Supplier   = context.Suppliers.Where(x => x.SupplierID == key).FirstOrDefault();
                    item.Category   = context.Categories.Where(category => category.CategoryID == item.CategoryID).FirstOrDefault();
                    model.InsertOnSubmit(item);
                    context.SubmitChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var querymodel = context.Products.Where(it => it.SupplierID == key);

            return(PartialView("_ProductsGridViewPartial", querymodel));
        }