public JsonResult Display() { ProductCategoryDAL ProdCatObj = new ProductCategoryDAL(); List <ProductCategory> catlist = new List <ProductCategory>(); try { var result = ProdCatObj.getAllProductCategory(); foreach (var obj in result) { ProductCategory cat = new ProductCategory(); cat.CategoryId = obj.CategoryId; cat.CategoryName = obj.CategoryName; catlist.Add(cat); } return(Json(catlist)); } catch (Exception) { return(null); } }