public ActionResult Edit([Bind("ixMaterial,sMaterial,sDescription,ixMaterialType,ixBaseUnit,bTrackSerialNumber,bTrackBatchNumber,bTrackExpiry,nDensity,ixDensityUnit,nShelflife,ixShelflifeUnit,nLength,ixLengthUnit,nWidth,ixWidthUnit,nHeight,ixHeightUnit,nWeight,ixWeightUnit")] MaterialsPost materials) { if (ModelState.IsValid) { materials.UserName = User.Identity.Name; _materialsService.Edit(materials); return(RedirectToAction("Index")); } //Custom Code Start | Replaced Code Block //Replaced Code Block Start //ViewBag.ixBaseUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit); //ViewBag.ixDensityUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit); //ViewBag.ixHeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit); //ViewBag.ixLengthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit); //ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType); //ViewBag.ixShelflifeUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit); //ViewBag.ixWeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit); //ViewBag.ixWidthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit); //Replaced Code Block End ViewBag.ixBaseUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementQuantity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit); ViewBag.ixHeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit); ViewBag.ixLengthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit); ViewBag.ixDensityUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementDensity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit); ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType); ViewBag.ixShelflifeUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementTime().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit); ViewBag.ixWeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementWeight().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit); ViewBag.ixWidthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit); //Custom Code End return(View(materials)); }