I've used PagedList.MVC for pagination in my application. This is working fine. Pagination is working fine and also the OrderBy dropdownlist is working fine. When i select value from dropdownlist it gives the desired sorted result. I mean if i select A-Z then it sorts the items fine in ascending order but when i click 2nd page or next page it doesn't sort any item and the url is become like this 

<http://localhost:41213/Home/Products?page=2&pageSize=6>

And also how can I make this pageSize=6 a dynamic ? I want this to put in dropdownlist like {5,10,15,20} and when user selects a value then it should display that selected numbers of item.

**Controller**

```
    [HttpGet]
    public ActionResult Products(int? OrderBy, int page=1, int pageSize=6)
    {
        private Shopping db = new Shopping();
        switch (OrderBy)
        {
            case 1:
                List<Product> listProductsasc = db.Products.OrderBy(p => p.Name).ToList();
                PagedList<Product> modelasc = new PagedList<Product>(listProductsasc, page, pageSize);
                return View(modelasc);
            case 2:
                List<Product> listProductsdesc = db.Products.OrderByDescending(p => p.Name).ToList();
                PagedList<Product> modeldesc = new PagedList<Product>(listProductsdesc, page, pageSize);
                return View(modeldesc);
            default:
                List<Product> listProducts = db.Products.ToList();
                PagedList<Product> modeldefault = new PagedList<Product>(listProducts, page, pageSize);
                return View(modeldefault);
        }
    }

```

**View**

```
@model PagedList.IPagedList<FypStore.Models.Product>
@using PagedList.Mvc
<div class="row">
        <div class="col-sm-6">
            @using (Html.BeginForm("Products", "Home", FormMethod.Get, new { id = "Form1" }))
            {
                <div class="col-sm-8">
                    Sort by:
                    @Html.DropDownList("OrderBy", new List<SelectListItem>

                     {
                        new SelectListItem{ Text="A-Z", Value = "1" },
                        new SelectListItem{ Text="Z-A", Value = "2" }
                     }, "-- Order By --")

                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <input type="submit" class="btn btn-default" value="Filter" />
                        </div>
                    </div>
                </div>
            }
        </div>
</div>
<br />

@Html.PagedListPager(Model, page => Url.Action("Products", new { page, pageSize = Model.PageSize }))
Showing @Model.FirstItemOnPage to @Model.LastItemOnPage of @Model.TotalItemCount Products

```