Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:49:10+00:00 2026-06-18T08:49:10+00:00

I am developing a web survey application in ASP.Net Mvc3. I use PagedList in

  • 0

I am developing a web survey application in ASP.Net Mvc3. I use PagedList in my application to paginate the questions page alone.

I get the following error:

The model item passed into the dictionary is of type
'PagedList.PagedList`1[SWSSMVC.Models.ViewModels.QuestionViewModel]', 
but this dictionary requires a model item of type 
'PagedList.IPagedList`1[SWSSMVC.Models.ViewModels.QuestionListViewModel]'.

There is a question which is of similar nature. The solution says not to specify anonymous type, as far as I understood. Can someone point out where in my code I have anonymous type? I believe I have typed all my variables with appropriate models.

This is the question Controller:

public class QuestionController : SessionController
{
    DBManager dbmgr = new DBManager();

    //
    // GET: /Question/

    public ActionResult Index(string currentSection, string currentPage, int? page)
    {
        int j;

        SectionSession = currentSection;
        PageSession = currentPage;

        var questionList = new QuestionListViewModel();

        int questionCount = dbmgr.getQuestionCount(currentPage);
        var question = new QuestionViewModel();
        for(int i=1 ; i<=questionCount; i++)
        {
            int questionid = dbmgr.getQuestionid(currentPage, i);
            string questiontext = dbmgr.getQuestion(questionid);

            List<string> oldchoices = dbmgr.getChoicesAns(questionid);
            ChoiceViewModel choice = new ChoiceViewModel();
            question = new QuestionViewModel { QuestionId = questionid, QuestionText = questiontext, Answer = oldchoices.Last()};

            for (j = 0; j < oldchoices.Count() - 1; j++)
            {
                if (oldchoices[j] != null)
                {
                    question.Choices.Add(new ChoiceViewModel { ChoiceId = j, ChoiceText = oldchoices[j] });
                }
            }
            questionList.Questions.Add(question);
        }

        int pageSize = 3;
        int pageNumber = (page ?? 1);

        return View(questionList.Questions.ToPagedList(pageNumber, pageSize));
    }

There are two models:

public class QuestionViewModel
{
    public int QuestionId { get; set; }
    public string QuestionText { get; set; }
    public List<ChoiceViewModel> Choices { get; set; }
    public string Answer { get; set; }
    [Required]
    public string SelectedAnswer { get; set; }
    public QuestionViewModel()
    {
        Choices = new List<ChoiceViewModel>();
    }
}

public class QuestionListViewModel
{
    public List<QuestionViewModel> Questions { set; get; }
    public QuestionListViewModel()
    {
        Questions = new List<QuestionViewModel>();
    }
}

I am entering my part- Index View code for the above Question Controller

@model PagedList.IPagedList<SWSSMVC.Models.ViewModels.QuestionListViewModel>
@{
    ViewBag.Title = "Index";
 }

 <h2>Questions</h2>

 @using (Html.BeginForm())
 {
    @Html.ValidationSummary(true)
    <fieldset>
       @foreach (var item in Model)
       {
           @Html.EditorFor(x => item.Questions)
       }

I also have a Editor Template like this

@model SWSSMVC.Models.ViewModels.QuestionViewModel
<div>
@Html.HiddenFor(x => x.QuestionId)
<h3> @Model.QuestionText </h3>
@foreach (var a in Model.Choices)
{
   <p>
      @Html.RadioButtonFor(b => b.SelectedAnswer, a.ChoiceText)  @a.ChoiceText 
   </p>
}
</div>

I tried to run through the code a couple of times and having hard time figuring it out. I also do not know how I could have made the questionList as a LINQ variable, given that, my questionList is inturn constructed with questions and choices from a separate model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:49:11+00:00Added an answer on June 18, 2026 at 8:49 am

    Creator of PagedList here. The problem is that this line:

    return View(questionList.Questions.ToPagedList(pageNumber, pageSize));
    

    Is sending a model of type IPagedList down to the page (because the extension method is being applied to a type of List), but your page says it is expecting:

    @model PagedList.IPagedList<SWSSMVC.Models.ViewModels.QuestionListViewModel>
    

    Changing your view code to say this instead should fix it:

    @model PagedList.IPagedList<SWSSMVC.Models.ViewModels.QuestionViewModel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If developing web applications using ASP.NET MVC or Ruby on Rails make the application
I am developing web application in ASP.NET and C#, in which a user should
I am developing web-application using Google Maps API and ASP.NET Ajax. Here is my
I am developing web based application using asp.net and ajax . Today I am
I'm developing web application using ASP.NET MVC + WCF secured by WIF. I'm using
I'm developing web application supported by Spring Integration. I'm using 1.0.4.RELEASE. I use CGLib
I am developing a very small survey application, likely 3-4 pages web application. so
I am developing Web Application in Java using Spring Framework. On one page, I
I'm new to developing web apps using ASP.NET MVC. In fact, I'm rather new
I am developing web app using ASP.NET and i am also using javascript in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.