私は単純なテーブルのJQGridを作成しようとしています。 VBで通じ以下はJQGrid with ASP.Net MVC with VB.Net
http://www.qa.downappz.com/questions/jqgrid-sorting-in-vb-net-mvc-app.html
から
http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx
からバージョンを翻訳
後、私は自分のデータベースにそれを修正して、この機能
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
を思い付い
グリッドはデータなしで表示し、システムがエラーをスローします
エラーの説明は 『のSystem.Object』を入力するタイプ 『可能System.Int32』をキャストする
」できませんと言います。エンティティへのLINQのみエンティティデータモデルのプリミティブ型のキャストサポートしています。」
をすべてのヘルプは、これはいくつかの基本的な誤解によるものであれば、私を導いてください、高く評価され、私はいくつかのハードワークをしても構わないと思っています。
ありがとうございました
編集:最後にオレグの提案につきとして働いていたコード
あなたは 1ステップでrows
プロパティを埋めるためにしようと問題は、あなたがEを使用することである
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
は、返信いただきありがとうございます、はい、私は彼らが – skv
感謝を分離することによって、あなたのソリューションを試してみましたあなたの答えは、はい、私はそれらのコードを分離することによってあなたのソリューションを試してみました、私はこの結果を達成するためにオブジェクトを作成しなければならなかった、そしてjsonはデータが埋め込まれているように見えるが、どういうわけか私のページは表示されませんが、あなたの提案はオリジナルの問題を解決しましたので、大変ありがとうございます。 – skv
他のフォーラムで働いていたコードを投稿しました。ここでは同じ質問を投稿できません。http://forums.asp.net/p/ 1786677/4910852.aspx/1?p = True&t = 634689228293174596 – skv