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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:39:59+00:00 2026-06-01T01:39:59+00:00

I am trying to make a JQGrid for a simple table. After following through

  • 0

I am trying to make a JQGrid for a simple table.

After following through with a VB translated version from

http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx

from

http://www.qa.downappz.com/questions/jqgrid-sorting-in-vb-net-mvc-app.html

I modified it to my own database and came up with this function

Public Function SelectGridData(ByVal sidx As String, ByVal sord As String, ByVal page As Integer, ByVal rows As Integer) As ActionResult
  Dim context As New IssueDBEntities
  Dim pageIndex As Integer = Convert.ToInt32(page) - 1
  Dim pageSize As Integer = rows
  Dim totalRecords As Integer = context.Issues.Count()
  Dim totalPages As Integer = CInt(Math.Ceiling(CSng(totalRecords) / CSng(pageSize)))

  Dim jsonData = New With { _
    .total = totalPages, _
    .page = page, _
    .records = totalRecords, _
    .rows = (From p In context.Issues _
        Order By (p.ID & " " & sord) _
        Select New With {.id = p.ID, .cell = _
                     {p.ID, p.Image_Path, p.Magazine_Type,p.Magazine_Path}}).ToArray()}

   Return Json(jsonData, JsonRequestBehavior.AllowGet)
End Function

The grid does show up without any data, and the system throws an error

The error description says

“Unable to cast the type ‘System.Int32’ to type ‘System.Object’. LINQ to Entities only supports casting Entity Data Model primitive types.”

Any help is appreciated, if this is due to some basic misunderstanding, please guide me, I am willing to do some hard work.

Thank you

Edit: The code that finally worked as per Oleg’s Suggestion

Dim Simple_Object As IQueryable(Of Object)
        Dim Second_Simple_Object As IQueryable(Of Object)

        Dim My_Array As Array
        Dim My_Second_Array As Array

        Simple_Object = From p In Context.Issues _
                     Order By (p.ID & " " & sord) _
                Select New With {p.ID, p.Image_Path, p.Magazine_Type, p.Magazine_Path}

        My_Array = Simple_Object.ToArray()

        Second_Simple_Object = From p In Context.Issues _
                     Order By (p.ID & " " & sord) _
                Select New With {p.ID}

        My_Second_Array = Second_Simple_Object.ToArray()

        Dim My_Result(0) As My_Record_Type

        For i = 0 To My_Array.GetLength(0) - 1
            If i > 0 Then
                ReDim Preserve My_Result(i)
            End If

            My_Result(i) = New My_Record_Type

            My_Result(i).id = CInt(My_Second_Array(i).ID)
            My_Result(i).Cell = {My_Array(i).ID.ToString, My_Array(i).Image_Path.ToString, _
                                    My_Array(i).Magazine_Type.ToString, My_Array(i).Magazine_Path.ToString}
        Next

Class My_Record_Type
    Public id As Integer
    Public Cell As String()
End Class
  • 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-01T01:40:01+00:00Added an answer on June 1, 2026 at 1:40 am

    You try to fill rows property in one step. The problem is that you use Entity Framework which have some restrictions in the conversion of the data types. You can solve the problem if you first make query to get the items which you need without any data conversion and save intermediate results as List of items. After that you can make another LINQ Query where you include explicit conversion of p.ID to string. Moreover your current code don’t use any paging of data. So the user will never seen more as the first page if you don’t use loadonce: true.

    It’s difficult for me to write correct code in VB without debugging it. I use C# instead since last years. I recommend you to look at the answer for more information. It contains implementation of the server side filtering. If you don’t need it and remove the corresponding code the rest code will be very short and I hope it will be easy to understand.

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

Sidebar

Related Questions

Trying to make a MySQL-based application support MS SQL, I ran into the following
After trying to make a while(bool) loop and it failing because I couldn't see
im trying make one replace in string from a array but this dont work
I'm trying make my first python app. I want make simple email sender form.
Trying to make a simple toggle menu, and I can't seem to hide/show the
Trying to make this simple applet - the first part just creates a simple
I'm trying to make instrument to simplify work with complex grids of jqGrid ,
first of all, thanks for your time. I'm trying to use jqGrid to make
I'm trying make a simple control, with a some path in it. And binding
I'm trying to make a change to an old appengine application, but now after

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.