Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. @model IEnumerable<Product>
  2.  
  3. @{
  4. ViewBag.Title = "grid";
  5. WebGrid grid = new WebGrid(Model, rowsPerPage: 5 );
  6. }
  7.  
  8. @grid.GetHtml(
  9.  
  10. tableStyle: "table",
  11. fillEmptyRows: true,
  12. headerStyle: "main-box-header clearfix",
  13. footerStyle: "pagination pull-right",
  14.  
  15. mode: WebGridPagerModes.All, //paging to grid
  16. firstText: "<< First",
  17. previousText: "< Prev",
  18. nextText: "Next >",
  19. lastText: "Last >>",
  20.  
  21. columns: new[] // colums in grid
  22. {
  23. grid.Column("Id"), //the model fields to display
  24. grid.Column("Name" ),
  25. grid.Column("Description"),
  26. grid.Column("Quantity"),
  27.  
  28. })
  29.  
  30. public ActionResult WebgridSample()
  31. {
  32. List<Product> inventoryList = new List<Product>();
  33.  
  34. inventoryList.Add(new Product
  35. {
  36. Id = "P101",
  37. Name = "Computer",
  38. Description = "All type of computers",
  39. Quantity = 800
  40. });
  41. inventoryList.Add(new Product
  42. {
  43. Id = "P102",
  44. Name = "Laptop",
  45. Description = "All models of Laptops",
  46. Quantity = 500
  47. });
  48. inventoryList.Add(new Product
  49. {
  50. Id = "P103",
  51. Name = "Camera",
  52. Description = "Hd cameras",
  53. Quantity = 300
  54. });
  55. inventoryList.Add(new Product
  56. {
  57. Id = "P104",
  58. Name = "Mobile",
  59. Description = "All Smartphones",
  60. Quantity = 450
  61. });
  62. inventoryList.Add(new Product
  63. {
  64. Id = "P105",
  65. Name = "Notepad",
  66. Description = "All branded of notepads",
  67. Quantity = 670
  68. });
  69. inventoryList.Add(new Product
  70. {
  71. Id = "P106",
  72. Name = "Harddisk",
  73. Description = "All type of Harddisk",
  74. Quantity = 1200
  75. });
  76. inventoryList.Add(new Product
  77. {
  78. Id = "P107",
  79. Name = "PenDrive",
  80. Description = "All type of Pendrive",
  81. Quantity = 370
  82. });
  83.  
  84. return View(inventoryList);
  85.  
  86. }
  87.  
  88. public ActionResult WebgridSample(int pageNum = 1, int pageSize = 5, string sortColumnName = "", string sortOrder = "desc")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement