Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. mycode

mycode

Scheduled Pinned Locked Moved - Uncategorised posts -
csharpcssasp-netdatabaselinq
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11683062
    wrote on last edited by
    #1

    using MvcPagingApp.Models; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Mvc; using PagedList.Mvc; using PagedList; namespace MvcPagingApp.Controllers { public class EmployeeController : Controller { // // GET: /Employee/ public ActionResult Index(string searchBy, string search) { Connection con = new Connection(); if (searchBy == "Gender") { return View(con.Employees.Where(x => x.Gender == search || search == null).ToList()); } else { return View(con.Employees.Where(x => x.Name == search || search == null).ToList()); // return View(con.Employees.Where(x => x.Name.StartsWith(search) || search == null).ToList()); } } public ActionResult grid(string searchBy, string search) { List lmd = new List(); // creating list of model. Connection con = new Connection(); // connection to getdata. List employees = con.Department.ToList(); ViewBag.Names = new SelectList(con.Department, "DeptID", "DeptName");// To display drop box //ViewBag.saveEmp = con.SaveEmployees(); if (searchBy == "Gender") { ViewBag.Data = con.Employees.Where(x => x.Gender == search || search == null).ToList(); } else { ViewBag.Data = con.Employees.Where(x => x.Name.StartsWith(search ?? "a", StringComparison.OrdinalIgnoreCase) || search == null).ToList(); // return View(con.Employees.Where(x => x.Name.StartsWith(search) || search == null).ToList()); } foreach (var dr in ViewBag.Data) { lmd.Add(new Employee { ID = dr.ID.ToString(), Name = dr.Name.ToString(), Gender = dr.Gender.ToString(), Email = dr.Email.ToString(), //Roles = dr.Roles.ToString(), }); } if (ViewBag.Data.Count == 0) { string s = "No records match search criteria"; } return View(lmd); } public PartialViewResult Searchgrid(string sear

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups