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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:18:33+00:00 2026-05-31T04:18:33+00:00

I’m trying JQGrid ASP.NET MVC2 version. Created a model and the controller: var itemsGridModel

  • 0

I’m trying JQGrid ASP.NET MVC2 version.

Created a model and the controller:

    var itemsGridModel = new OrderItemsjqGridModel();
    itemsGridModel.OrderItemsGrid.DataUrl = Url.Action("ItemsDataRequested", new {OrderID = OrderID, CustomerID = CustomerID });
    orderVM.orderItemsGrid = itemsGridModel;


    return View(orderVM);

The ItemsDataRequested:

public JsonResult ItemsDataRequested(int OrderID, int CustomerID)
{
    // Get both the grid Model and the data Model

    var gridModel = new OrderItemsjqGridModel();
    var orderItems = ordersRepository.GetOrder(OrderID).ItemsInOrders.ToList();

    IQueryable<ItemsInOrder> myItems = orderItems.AsQueryable<ItemsInOrder>();

    return gridModel.OrderItemsGrid.DataBind(myItems);
}

I get a NullReferenceException in the last line.
The myItems has 1 Item with all values filled.

Any Idea what am I doing wrong ?

Thanks.

StackTrace:

   at Trirand.Web.Mvc.Util.PrepareJsonResponse(JsonResponse response, JQGrid grid, DataTable dt)
   at Trirand.Web.Mvc.Util.ConvertToJson(JsonResponse response, JQGrid grid, DataTable dt)
   at Trirand.Web.Mvc.JQGrid.FilterDataSource(Object dataSource, NameValueCollection queryString, IQueryable& iqueryable)
   at Trirand.Web.Mvc.JQGrid.GetJsonResponse()
   at Trirand.Web.Mvc.JQGrid.DataBind()
   at Trirand.Web.Mvc.JQGrid.DataBind(Object dataSource)
   at TechRun.UI.Controllers.OrdersController.ItemsDataRequested(Int32 OrderID, Int32 CustomerID) in y:\work\yosi\source\Techrun\TechRun.UI\Controllers\OrdersController.cs:line 118
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

Model:

public class OrderItemsjqGridModel
{
    public JQGrid OrderItemsGrid { get; set; }

public OrderItemsjqGridModel()
{            
    OrderItemsGrid = new JQGrid
                     {
                         Columns = new List<JQGridColumn>()
                         {
                             new JQGridColumn { DataField = "OrderID", 
                                                // always set PrimaryKey for Add,Edit,Delete operations
                                                // if not set, the first column will be assumed as primary key
                                                PrimaryKey = true,
                                                Editable = false,
                                                Width = 30 },
                             new JQGridColumn { DataField = "ItemID",
                                                PrimaryKey = true,
                                                Editable = true,
                                                Width = 120},
                             new JQGridColumn { DataField = "ItemDescription", 
                                                Editable = true,
                                                Width = 300},
                             new JQGridColumn { DataField = "NumOfItems", 
                                                Editable = true,
                                                Width = 50
                                                },
                             new JQGridColumn { DataField = "CostOfItem", 
                                                Editable = true,
                                                Width = 75 },
                             new JQGridColumn { DataField = "TotalCost",
                                                Editable =  false
                                              },
                             new JQGridColumn { DataField = "SuppolyDate", 
                                                Editable = true,
                                                Width = 120, 
                                                DataFormatString = "{0:d}" },
                         },
                         Width = Unit.Pixel(640),
                         Height = Unit.Percentage(100)
                     };

    OrderItemsGrid.ToolBarSettings.ShowRefreshButton = true;
    OrderItemsGrid.ToolBarSettings.ShowAddButton = true;
    OrderItemsGrid.ToolBarSettings.ShowDeleteButton = true;
    OrderItemsGrid.ToolBarSettings.ShowEditButton = true;
}

}
  • 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-05-31T04:18:34+00:00Added an answer on May 31, 2026 at 4:18 am

    I know this is an old question, but I was looking for a solution for the same problem with no luck, I have returned back to my code for more exception analysis, and I found the solution, I prefered to log it here so anybody has the same problem would be satisfied.

    I have discovered the reason, the Model JGridColumn names are different than the returned SQL query fields, there was a spelling mistake in one of the the Model columns.

    Make sure all JGrid columns’ names are identical with the SQL query columns’ names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.