TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yogesh Vedpathak
669
1.4k
197.7k
The name(sort) Does not exist in current context
Dec 13 2017 2:15 AM
// Here Is My Code
using DemoGrids.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace DemoGrids.Controllers
{
public class DemoController : Controller
{
// GET: Demo
public ActionResult Index()
{
return View();
}
public JsonResult GetCustomers(String Word, int Page, int rows, string searchString)
{
using (DatabaseContext db = new DatabaseContext())
{
int PageIndex = Convert.ToInt32(Page) - 1;
int PageSize = rows;
var Results = db.Customers.Select(
a => new
{
a.CustomerId,
a.ContactName,
a.ContactTitle,
a.City,
a.PostalCode,
a.Country,
a.Phone,
});
int totalRecords = Results.Count();
var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
// I a m Getting Error Here Below Line
if (sort.ToUpper() == "DESC")
{
Results = Results.OrderByDescending(s => s.CustomerId);
Results = Results.Skip(PageIndex * PageSize).Take(PageSize);
}
else
{
Results = Results.OrderBy(s => s.CustomerId);
Results = Results.Skip(PageIndex * PageSize).Take(PageSize);
}
if (!string.IsNullOrEmpty(searchString))
{
Results = Results.Where(m => m.Country == searchString);
}
var jsonData = new
{
total = totalPages,
Page,
records = totalRecords,
rows = Results
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
}
}
}
Reply
Answers (
2
)
array display in order
Generate .NET Standard 2.0 DLL using Roslyn?