title: Asp.net MVC Compiler Error Message: CS1061:
body: <p>I am adding pagination in my project after adding all the code it show following error.</p>
  
  <blockquote>
    <p>Compiler Error Message: CS1061:
    'System.Collections.Generic.IEnumerable' does
    not contain a definition for 'Pagination' and no extension method
    'Pagination' accepting a first argument of type
    'System.Collections.Generic.IEnumerable' could
    be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;h2
  Online Store
  &lt;/h2&gt;
  @foreach (var item in Model)
  {
  
  &lt;div style="display:inline-block"&gt;
      &lt;div style="width:30%; float:left;"&gt;
          &lt;img src="@item.Image" width="170" height="276"             alt="@item.ProductName" title="@item.ProductName"&gt;
      &lt;/div&gt;
      &lt;div style="width:70%; float:left;"&gt;
  
          &lt;h3&gt;
              @Html.DisplayFor(modelItem =&gt; item.ProductName)
          &lt;/h3&gt;
  
          &lt;p&gt;
              @Html.DisplayFor(modelItem =&gt; item.Description)
          &lt;/p&gt;
  
          &lt;p&gt;
              $@Html.DisplayFor(modelItem =&gt; item.Price)
          &lt;/p&gt;
  
          &lt;p&gt;
              @Html.ActionLink("More Info", "Index", "ItemDetail", new { id = item.ProductID }, new { id = "ProductID" })
          &lt;/p&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt; }
  &lt;div class="pager"&gt;
  @Html.PageLinks(Model.Pagination, x =&gt; Url.Action("Index", new { page = x         }))
  </code></pre>
  
  <p></p>
  
  <p><strong>Model:</strong> </p>
  
  <pre><code>namespace ISkills.Models
  {
  public class PaginationModel
  {
  
      public int TotalItems { get; set; }
      public int ItemsPerPage { get; set; }
      public int CurrentPage { get; set; }
  
      public int TotalPages
      {
          get { return (int)Math.Ceiling((decimal)TotalItems / ItemsPerPage);    }
  
      }
  </code></pre>
  
  <p><strong>Controller:</strong> </p>
  
  <pre><code>private ISkillsContext db = new ISkillsContext();
      private const int PAGE_SIZE = 3;
  
  
      public ActionResult Index( int page =1)
      {
          var data = db.Products.Select(p =&gt; p)
              .OrderBy(p =&gt; p.ProductName)
              .Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE);
  
          ProductsModel model = new ProductsModel
          {
              Products = data,
              Pagination = new PaginationModel
              {
                  CurrentPage = page,
                  ItemsPerPage = PAGE_SIZE,
                  TotalItems = db.Products.ToList().Count()
              }
          };
  </code></pre>
  
  <p><strong>HTML Helper:</strong></p>
  
  <pre><code>namespace ISkills.HtmlHelpers
  {
  public static class PaginationHelper
  {
      public static MvcHtmlString PageLinks(this HtmlHelper htmlHelper,
                                           PaginationModel pagination,
                                           Func&lt;int, string&gt; pageUrl)
      {
  
          StringBuilder result = new StringBuilder();
          for (int i = 1; i &lt;= pagination.TotalPages; i++)
          {
              TagBuilder tag = new TagBuilder("a");
              tag.MergeAttribute("href", pageUrl(i));
              tag.InnerHtml = i.ToString();
              if (i == pagination.CurrentPage)
              {
                  tag.AddCssClass("selected");
                  tag.AddCssClass("btn-primary");
              }
              tag.AddCssClass("btn btn-default");
              result.Append(tag.ToString());
          }
          return MvcHtmlString.Create(result.ToString());
      }
  }
  }
  </code></pre>
  
  <p><strong>Can any one help me, How to resolve this error ?</strong></p>