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 8865573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:32:46+00:00 2026-06-14T16:32:46+00:00

I am working on a page where I have a dropdownlist. Once the user

  • 0

I am working on a page where I have a dropdownlist. Once the user makes a selection, the Client side Change event will load a Telerik Grid based off of the dropdownlist’s selection. The issue I’m encountering currently is when I try to load the page, I get the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 30:         <tr>
Line 31:             <td colspan="2">
Line 32:                 @(Html.Telerik().Grid<ProductModel>(Model.Products.Data)
Line 33:                     .Name("classification-products-grid")
Line 34:                     .Columns(columns =>

Below is all of my code. If anyone has any ideas, I’d appreciate it. Thanks.

Model (ClassificationListModel.cs)

public partial class ClassificationListModel : BaseNopModel
{
    public ClassificationListModel()
    {
        Classifications = new List<ClassificationModel>();
    }

    [NopResourceDisplayName("Admin.Reports.Classifications.Classification")]
    public int Classification { get; set; }
    public List<ClassificationModel> Classifications { get; set; }

    public GridModel<ProductModel> Products { get; set; }
}

public partial class ClassificationModel : BaseNopModel
{
    public int Id { get; set; }
    public string Name { get; set; }
}

View (Classifications.cshtml)

@model ClassificationListModel
@using Nop.Admin.Models.Reports;
@using Telerik.Web.Mvc.UI;
@{
var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSize;
ViewBag.Title = @T("Admin.Reports.Classifications").Text;
}
@using (Html.BeginForm())
{
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-catalog.png")" alt="" />
        @T("Admin.Reports.Classifications")
    </div>
</div>

<table width="100%">
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Classification)
        </td>
        <td class="adminData">
            @Html.DropDownListFor(model => model.Classification, new SelectList(Model.Classifications, "Id", "Name"), "Select a Classification")
        </td>
    </tr>
    <tr>
        <td colspan="2">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            @(Html.Telerik().Grid<ProductModel>(Model.Products.Data)
                .Name("classification-products-grid")
                .Columns(columns =>
                {
                    columns.Bound(x => x.Id)
                        .ReadOnly(true)
                        .Visible(false);
                    columns.Bound(x => x.Name);
                    columns.Bound(x => x.Published)
                        .Width(100)
                        .Template(x => x.Published.ToString().ToLower())
                        .Centered();
                })
                .Pageable(settings => settings.Total(Model.Products.Total).PageSize(gridPageSize).Position(GridPagerPosition.Both))
                .ClientEvents(events => events.OnDataBinding("onDataBinding"))
                .DataBinding(dataBinding => dataBinding.Ajax().Select("ProductList", "Reports"))
                .EnableCustomBinding(true))
        </td>
    </tr>
</table>

<script type="text/javascript">
    $(document).ready(function () {
        $("#Classification").change(function () {
            $("#classification-products-grid").data("tGrid").rebind();
        });
    });

    function onDataBinding(e) {
        var specificationOptionId = $("#Classification").data("tDropDownList").value();

        if (specificationOptionId != 0)
            e.data = $.extend(e.data, {
                specificationOptionId: $("#Classification").data("tDropDownList").value()
            });
    }
</script>
}

Controller (ReportsController.cs)

[AdminAuthorize]
public class ReportsController : BaseNopController
{
    #region Fields
    private readonly IPermissionService _permissionService;
    private readonly IProductService _productService;
    private readonly ISpecificationAttributeService _specificationAttributeService;
    private readonly IWorkContext _workContext;
    #endregion

    #region Constructor
    public ReportsController(IPermissionService permissionService, IProductService productService,
        ISpecificationAttributeService specificationAttributeService, IWorkContext workContext)
    {
        this._permissionService = permissionService;
        this._productService = productService;
        this._specificationAttributeService = specificationAttributeService;
        this._workContext = workContext;
    }
    #endregion

    #region Utilities
    [NonAction]
    private List<ClassificationModel> PrepareClassificationListModel(IList<SpecificationAttributeOption> specificationAttributeOptions)
    {
        var returnData = new List<ClassificationModel>();

        foreach (var specificationAttributeOption in specificationAttributeOptions)
        {
            var classification = new ClassificationModel
            {
                Id = specificationAttributeOption.Id,
                Name = specificationAttributeOption.Name
            };
            returnData.Add(classification);
        }

        return returnData;
    }
    #endregion

    #region Methods
    #region Classifications
    public ActionResult Index()
    {
        return RedirectToAction("Classifications");
    }

    public ActionResult Classifications()
    {
        var classificationListModel = new ClassificationListModel();
        var specificationAttributeOptions = _specificationAttributeService.GetSpecificationAttributeOptionsBySpecificationAttribute(5);
        var classifications = PrepareClassificationListModel(specificationAttributeOptions);
        classificationListModel.Classifications = classifications;
        return View(classificationListModel);
    }

    [HttpPost, GridAction(EnableCustomBinding = true)]
    public ActionResult ProductList(GridCommand command, int specificationOptionId)
    {
        if (!_permissionService.Authorize(StandardPermissionProvider.ManageReports))
            return AccessDeniedView();

        if (specificationOptionId == 0)
            return View();

        var gridModel = new GridModel();
        IList<int> filterableSpecificationAttributeOptionIds = new List<int> { specificationOptionId };
        var products = _productService.SearchProducts(0, 0, null, null, null, 0, null, false,
                _workContext.WorkingLanguage.Id, null,
                ProductSortingEnum.Position, command.Page, command.PageSize,
                true, out filterableSpecificationAttributeOptionIds);

        gridModel.Data = products.Select(x =>
        {
            var productModel = x.ToModel();
            return productModel;
        });
        gridModel.Total = products.TotalCount;

        return new JsonResult
        {
            Data = gridModel
        };
    }
    #endregion
    #endregion
}
  • 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-14T16:32:48+00:00Added an answer on June 14, 2026 at 4:32 pm

    Okay, so I found the answer. Here is a link to the topic that had it:

    Solution

    Here are my changes also.

    View (Classifications.cshtml)

    @model ClassificationListModel
    @using Nop.Admin.Models.Reports;
    @using Telerik.Web.Mvc.UI;
    @{
    var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSize;
    ViewBag.Title = @T("Admin.Reports.Classifications").Text;
    }
    @using (Html.BeginForm())
    {
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-catalog.png")" alt="" />
            @T("Admin.Reports.Classifications")
        </div>
    </div>
    
    <table width="100%">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Classification):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.Classification, new SelectList(Model.Classifications, "Id", "Name"), "Select a Classification")
            </td>
        </tr>
        <tr>
            <td colspan="2">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="divGrid" style="display:none">
                    @(Html.Telerik().Grid<ProductModel>(Model.Products.Data)
                        .Name("classification-products-grid")
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.Id)
                                .ReadOnly(true)
                                .Visible(false);
                            columns.Bound(x => x.Name);
                            columns.Bound(x => x.Published)
                                .Width(100)
                                .Template(x => x.Published.ToString().ToLower())
                                .Centered();
                        })
                        .Pageable(settings => settings.Total(Model.Products.Total).PageSize(gridPageSize).Position(GridPagerPosition.Both))
                        .ClientEvents(events => events.OnDataBinding("onDataBinding"))
                        .DataBinding(dataBinding => dataBinding.Ajax().Select("ProductList", "Reports"))
                        .EnableCustomBinding(true))
                    </div>
            </td>
        </tr>
    </table>
    
    <script type="text/javascript">
        var initialLoad = true;
    
        $("#Classification").change(function () {
            $("#divGrid").show();            
            $("#classification-products-grid").data("tGrid").rebind();
        });
    
        function onDataBinding(e) {
            if (initialLoad == true) {
                e.preventDefault();
                initialLoad = false;
            }
            else {
                var classificationId = $('#@Html.FieldIdFor(model => model.Classification)').val();
                if (classificationId != "")
                    e.data = $.extend(e.data, {
                        specificationOptionId: classificationId
                    });
                else {
                    e.preventDefault();
                    $("#divGrid").hide();
                }
            }
    
        }
    </script>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with ASP.NET doing some client side javascript. I have the following
I have a DropDownList in my asp.net web page. The RequiredFieldValidator is not working.
What I have here is a PHP page working with the Facebook API. What
Here's the code for a simple page I have that is not working: <head>
Ok, I have page one(index), fully functional and working fine as is with all
I'm working on a mobile web app, and in my page I have a
I'm working on a web page where I have a dynamically generated table where
I am working with php and want to have a page that has a
I have been working with jQuery mobile 1.0.1. I have a page which drills
i have django installed and seems to be working it worked page I want

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.