views:

149

answers:

0

Hello All,

I am having a edit category form in which one of the field is status which is a checkbox and the datatype of that field is int in the database.

when I am selecting the checkbox I am getting an error which is as follows

The parameters dictionary contains a null entry for parameter 'status' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult EditCategory(Int32, System.String, System.String, System.String, System.String, Int32)' in 'ExportJquerygridtoexcel.Controllers.AdminController'. To make a parameter optional its type should be either a reference type or a Nullable type. Parameter name: parameters

what shall I do for this ,My code is as follows in admin controller class

public ActionResult EditCategory(int category_id, string category_name, string category_desc, string image_name, string img_content,int status)
{
    try
    {
        string s1, type;
        foreach (string inputTagName in Request.Files)
        {
            HttpPostedFileBase file = Request.Files[inputTagName];
            if (file.ContentLength > 0)
            {
                image_name = Path.GetFileName(file.FileName);
                img_content = Path.GetFileName(file.ContentType);

                file.SaveAs(HttpContext.Server.MapPath("/Content/upload_CatImg/") + image_name);
                System.Drawing.Size r = new Size(80, 80);
                System.Drawing.Image srcImage = System.Drawing.Image.FromFile(Server.MapPath("/Content/upload_CatImg/") + image_name);
                System.Drawing.Image tnImage = srcImage.GetThumbnailImage(r.Width, r.Height, null, IntPtr.Zero);
                System.Drawing.Graphics graphic = Graphics.FromImage(tnImage);
                System.Drawing.Rectangle rect = new Rectangle(0, 0, r.Width, r.Height);
                graphic.DrawImage(tnImage, rect);
                s1 = HttpContext.Server.MapPath("/Content/thumb_CatImg/") + image_name;
                tnImage.Save(s1);
                type = img_content;
            }
        }

        AdminImplementation _adminImplementation = new AdminImplementation();

        Boolean isfeature = Convert.ToBoolean(status);

        if (isfeature)
        {
            status = 0;
        }
        else
        {
            status = 1;
        }

        int i = _adminImplementation.**updateCategory**(category_id, category_name, category_desc, image_name, img_content,status );

        ViewData["imageName"] = image_name;
        ViewData["succm"] = "category updated successfully";
        IList<tbl_PRODUCT_CATEGORY> CategorybyId = _adminImplementation.fetchCategoryById(category_id);

        return View(CategorybyId.First());
    }
    catch 
    {
        return View();
    }
}

this updateCategory comes from the implementation class which is as follows:

 public int updateCategory(int category_id, string category_name, string category_desc, string image_name, string img_content,int status)
 {
     int itemUpdated = 0;

     using (EcommerceMVCEntities modelObject = new EcommerceMVCEntities())
     {

         tbl_PRODUCT_CATEGORY UpdateItem = (from c in modelObject.tbl_PRODUCT_CATEGORY
                                               where c.category_id.Equals(category_id)
                                               select c).ToList().First();

         UpdateItem.category_name = category_name;
         UpdateItem.category_desc = category_desc;
         UpdateItem.cat_img = image_name;
         UpdateItem.cat_imgcontent = img_content;
         UpdateItem.status = status;

         //  modelObject.SaveChanges();
         itemUpdated = modelObject.SaveChanges();
         modelObject.AcceptAllChanges();
     }

     return itemUpdated;
}

Please tell me where I am going wrong?

Thanks Ritz