Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:58:22+00:00 2026-06-07T00:58:22+00:00

This is my model class [HiddenInput(DisplayValue = false)] public long ProductId { get; set;

  • 0

This is my model class

   [HiddenInput(DisplayValue = false)]
    public long ProductId { get; set; }

    [Display(Name="Alarm Point")]
    public short AlarmPoint { get; set; }

    [Required]
    public long? MeasurementId { get; set; }

    [Display(Name="Measurement Id")]
    public IList<SelectListItem> Measurement { get; set; }


    [Display(Name="Length")]
    public decimal Length { get; set; }


    [Display(Name="Breadth")]
    public decimal Breadth { get; set; }


    [Display(Name="Height")]
    public decimal Height { get; set; }


    [Display(Name="Weight")]
    public decimal Weight { get; set; }


    [Display(Name="Is Active")]
    public bool IsActive { get; set; }


    [Display(Name="Is Sellable")]
    public bool IsSellable { get; set; }

and in my controller’s index page i just pass a value through Json.

   [GridAction]
    public ActionResult ProductList()
    {
        var collection = _productService.GetAllProduct().Select(x =>
            new ProductModel()
            {
                ProductId = x.ProductId,
                Title = x.Title,
                CategoryId = x.CategoryId,
                Description = x.Description,
                Barcode = x.Barcode,
                AlarmPoint = x.AlarmPoint.Value,
                MeasurementId = x.MeasurementId,
                Length = x.Length.Value,
                Breadth = x.Breadth.Value,
                Height = x.Height.Value,
                Weight = x.Weight.Value,
                IsActive = x.IsActive.Value,
                IsSellable = x.IsSellable.Value,
                IsPurchasable = x.IsPurchasable.Value
            });
        return Json(collection, JsonRequestBehavior.AllowGet);
    }

and this is my index view

          <h1 style="font-size: 25px ">View</h1>
           <br />
            @(Html.Telerik().Grid<CommerceSuite.Web.Models.Product.ProductModel>()
                           .Name("Product")
           .DataBinding(databinding =>
           {
               databinding.Ajax().Select("ProductList", "Product");
           })
           .Columns(columns =>
           {
               columns.Bound(p => p.ProductId)
               .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= ProductId #>' />")
               .Title("")
               .Width(20)
               .HtmlAttributes(new { style = "text-align:center" });
               columns.Bound(p => p.Title).Width(200);
               columns.Bound(p => p.ProductId).Width(200);
               columns.Bound(p => p.CategoryId).Width(200);
               columns.Bound(p => p.Barcode).Width(200);
               columns.Bound(p => p.ProductId)
               .ClientTemplate("<input type='button' name='<#=ProductId #>' onclick='csPopupOpen(\"Edit BillOf Material\",\"" + @Url.Action("Edit") + "\",<#=ProductId #>,\"" + @Url.Action("Index") + "\")' value='Edit' > <input type='button' name='<#=ProductId #>' onclick='csPopupOpen(\"Delete BillOf Material\",\"" + @Url.Action("Delete") + "\",<#=ProductId #>)' value='Delete' > ").Width(210);
           })
           .Pageable()
           .Scrollable()
           .Sortable()
     )

when i rum this code and click on a link i got a internal server 500 error on index view that is saying that nullable object must have a value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:58:23+00:00Added an answer on June 7, 2026 at 12:58 am

    Your problem is in here somewhere:

    var collection = _productService.GetAllProduct().Select(x =>
                new ProductModel()
                {
                    ProductId = x.ProductId,
                    Title = x.Title,
                    CategoryId = x.CategoryId,
                    Description = x.Description,
                    Barcode = x.Barcode,
                    AlarmPoint = x.AlarmPoint.Value,
                    MeasurementId = x.MeasurementId,
                    Length = x.Length.Value,
                    Breadth = x.Breadth.Value,
                    Height = x.Height.Value,
                    Weight = x.Weight.Value,
                    IsActive = x.IsActive.Value,
                    IsSellable = x.IsSellable.Value,
                    IsPurchasable = x.IsPurchasable.Value
                });
    

    In all the places where you are doing a .Value, you probably need to check that there is a value first, or use the null coalescing operator, e.g.:

    ...
    Length = x.Length ?? 0,
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My model class is like this: Public class abc { public string p1 get;
I have this model: class Journals(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code, max_length=50) name
I have this model: class blog(models.Model): user = models.ForeignKey(User) mail = models.EmailField(max_length=60, null=False, blank=False)
I've got this model: class Visit(models.Model): timestamp = models.DateTimeField(editable=False) ip_address = models.IPAddressField(editable=False) If a
Assume this model class : public class Car extends Vehicle implements Visitable { .....
Having this model class public class Usuario { #region Atributos private int _intID =
If I have this model: class Person(models.Model): name=models.CharField(max_length=28) mother=models.ForeignKey(self,null=True,blank=True) I am trying to make
I have a this model: class Fleet(models.Model): company = models.ForeignKey(Company, editable=False) aircraft = models.ForeignKey(Aircraft)
I have this model: class Category(models.Model): name = models.CharField() description = models.CharField(blank=True) parent =
I have this model: class Tag < ActiveRecord::Base # Validations validates :name, :presence =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.