Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2012, 04:11 AM
Registered User
 
Join Date: Sep 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default ASP MVC JSON ARRAY

Hi everyone,i am working on a mobile mvc application.I have the following code to get data from linq:



public class ShipperController : Controller
{
FxDataClassesDataContext dcfx = new FxDataClassesDataContext();

public ActionResult GridActiveQuotes(string sidx, string sord, int page, int rows)
{

int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
int totalRecords = dcfx.FxVwQuotes.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

var opp = (sord == "asc") ?
dcfx.FxVwQuotes
.Skip(pageIndex * pageSize)
.Take(pageSize)
:
dcfx.FxVwQuotes
.Skip(pageIndex * pageSize)
.Take(pageSize);

var jsonData = new
{
total = totalPages, // Work item
page = page,
records = totalRecords, // Work item
rows = (
from Quotes in dcfx.FxVwQuotes
select new
{
id = Quotes.Quote_ID,
cell = new string[] {
Quotes.Quote_ID.ToString(),
Quotes.Transporter_Name.ToString(),
Quotes.Transporter_Reputation_Score.ToString(),
Quotes.Opportunity_Cargo_Description.ToString(),
Quotes.Opportunity_Origin.ToString(),
Quotes.Opportunity_Origin_Country_Code.ToString(),
Quotes.Opportunity_Destination.ToString(),
Quotes.Opportunity_Destination_Country_Code.ToStri ng(),
Quotes.Quote_Currency.ToString(),
Quotes.Quote_Price.ToString()

}
}).ToArray()

};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}




I would like to display this array in a html listview or table on a .cshtml file(View).PLEASE HELP





Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i write JSON-encoded in asp.net vb? nir987 ASP.NET 3.5 Basics 31 October 29th, 2010 04:26 AM
Errors while upgrade theBeerHouse mvc project form asp.net mvc 1.0 to 2.0 vanbach1304 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 0 April 20th, 2010 06:43 AM
How to redirect a user after timeout in asp.net mvc? chobo2 ASP.NET 3.5 Basics 0 November 8th, 2009 10:29 PM
do I need to override AuthorizeTag? - Asp.net MVC chobo2 ASP.NET 3.5 Basics 0 September 27th, 2009 10:28 PM
TheBeerHouse MVC preview ASP.NET MVC Website Programming Problem Design Solution jminatel BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 July 18th, 2009 09:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.