// Update product details with image private bool EditUpdate() { objProduct = new Product(); objProductBiz = new ProductBiz(); HttpPostedFile postedFile = flUpdateProductImage.PostedFile; string fileName = Path.GetFileName(postedFile.FileName); string fileExtension = Path.GetExtension(fileName); int fileSize = postedFile.ContentLength; if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".png" || fileExtension.ToLower() == ".bmp" || fileExtension.ToLower() == ".gif" || fileSize == 0) { if (fileSize > 524288) { MessageBox("Image size should not be more than 512 Kbps"); ModalUpdateProduct.Show(); } else { Stream stream = postedFile.InputStream; BinaryReader binaryReader = new BinaryReader(stream); byte[] bytes = binaryReader.ReadBytes((int)stream.Length); objProduct.ProductImageName = fileName; objProduct.ProductImageSize = fileSize; objProduct.ProductImage = bytes; GridViewRow row = gvDisplayProduct.SelectedRow; objProduct.ProductId = Convert.ToInt16(gvDisplayProduct.DataKeys[row.RowIndex].Values[0].ToString()); objProduct.RegionId = Convert.ToByte(ddlRegion.SelectedValue); objProduct.FirstCategoryId = Convert.ToInt16(ddlFirstCategory.SelectedValue); objProduct.SecondCategoryId = Convert.ToInt16(ddlSecondCategory.SelectedValue); objProduct.ThirdCategoryId = Convert.ToInt16(ddlThirdCategory.SelectedValue); objProduct.ProductName = txtUpdateProductName.Text.Trim(); objProduct.ProductDescription = txtUpdateProductDescription.Text.Trim(); objProduct.BrandId = Convert.ToInt16(ddlBrand.SelectedValue); objProduct.MeasurementId = Convert.ToByte(ddlMeasurement.SelectedValue); objProduct.ProductSellPrice = Convert.ToDecimal(txtSellPrice.Text.Trim()); objProduct.Vat = Convert.ToDecimal(txtUpdateVat.Text.Trim()); objProduct.FoodScheduleId = Convert.ToByte(ddlFoodSchedule.SelectedValue); objProduct.IsActive = Convert.ToBoolean(ddlUpdateProductStatus.SelectedValue); objProduct.UpdatedBy = Convert.ToInt16(Session["UserId"]); objProductBiz.EditUpdate(objProduct); } } else { MessageBox("Please upload valid (jpg, png, gif & bmp) picture"); ModalUpdateProduct.Show(); } return(true); }