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 7552155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:41:20+00:00 2026-05-30T10:41:20+00:00

I am creating a forum application in mvc3… I have a link called Add

  • 0

I am creating a forum application in mvc3…

I have a link called Add New Comment on Post page where user can add the comments for that post… for creating new comment i have written following code….

 public ActionResult Addnew(int id)
    {
        Answer ans = new Answer();
        ans.QuestionQId = id;

        return View();
    }
    [HttpPost]
    public ActionResult Addnew(Answer ans,int id)
    {

        _db.Answers.Add(ans);
        _db.SaveChanges();
           return View("Details");
    }

but it is giving mean error whenever i try to save the code as follows:
Value cannot be null.
Parameter name: entity

I have two different table Question{id(pk), Question} and Answer{id(pk), ans, Qid(fk)}

All i want to do is While adding the comment for a perticular question, its Qid will be stored in answer database …..

Help me!!

View Related —

    @using (Html.BeginForm()) 
{ 
@Html.ValidationSummary(true)
 <fieldset> 
     <legend>Answer</legend> 
     <div class="editor-label">
       @Html.LabelFor(model => model.AId)
    </div> 
    <div class="editor-field">
      @Html.EditorFor(model => model.AId) 
      @Html.ValidationMessageFor(model => model.AId)
    </div>
    <div class="editor-label">
      @Html.LabelFor(model => model.Ans)
    </div> 
    <div class="editor-field">
      @Html.EditorFor(model => model.Ans) 
      @Html.ValidationMessageFor(model => model.Ans)
    </div>
    <div class="editor-label">
      @Html.LabelFor(model => model.QuestionQId)
    </div> <div class="display-field">
      @Html.DisplayFor(modelItem => modelItem.QuestionQId)
    </div> 
} 
  • 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-05-30T10:41:21+00:00Added an answer on May 30, 2026 at 10:41 am

    I think you are not passing the Answer object to the view, may caused the problem. have you tried following

    public ActionResult Addnew(int id)
        {
            Answer ans = new Answer();
            ans.QuestionQId = id;
    
            return View(ans);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am creating a MVC3 application where the user can be either an Admin
I have this code for creating a topic and post in a forum application
So within my application is a form for creating a new user, with relevant
I have an application which sends a POST request to the VB forum software
I'm working on MVC3 and currently creating a Forum application in asp.net. Forum allows
I am creating a form where a user will register with a struts2 application.
I am creating some tag functionality for a forum using linq2sql, and I have
In my Rails application I have a Forum with many Topics. From the Forum's,
I have a Windows form application that users can log into. The application is
I have a MVC 3 Razor web application that needs to allow creating and

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.