Hi
I have the following code to load data (30 to 30) as you scroll the page:
public ActionResult Index(int? pageNum, string searchString, bool checkControle = false)
{
pageNum = pageNum ?? 0;
ViewBag.IsEndOfRecords = false;
if (Request.IsAjaxRequest())
{
var projects = GetIndex(pageNum.Value, searchString, checkControl);
ViewBag.IsEndOfRecords = (projects.Any());
return PartialView("SubTable", projects);
}
else
{
var result = db.toList()
ProjectData = result.ToList();
ViewBag.TotalNumberProjects = ProjectData.Count;
ViewBag.Projects = GetIndex(pageNum.Value, searchStringl, checkControl);
return View("Index");
}
}
public List<OrdersColorsViewModel> GetIndex(int pageNum, string searchString, bool checkControl = false)
{
ProjectData = result.ToList();
int from = (pageNum * RecordsPerPage);
if (!String.IsNullOrEmpty(searchString))
{
// some code...
return tempList;
}
if (checkControle == false)
{
//some code...
return tempList;
}
else
{
var tempList = ProjectData.OrderBy(x => x.order.Order).Skip(from).Take(30).ToList<OrdersColorsViewModel>();
ViewBag.ModelCount = result.Count();
return tempList;
}
}
jquery in my index:
var url = '@Url.RouteUrl("ProjectDataList")';
$(window).scroll(scrollHandler);
I think I have a structure problem, so I summarized my code above.
Everything works correctly, I only have one problem when I value my variables string searchString and bool checkControl, but on the second call (srcoll) the value of my variables is cleared
I undestand that when I call my index again, it will give me the original values, will it be a solution to temporarily store this data?
How can i solve this problem in terms of structure?
Thanks for any help.