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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:49:47+00:00 2026-06-08T14:49:47+00:00

I am making a Blog using MVC 3, Razor and Entity Framework. I am

  • 0

I am making a Blog using MVC 3, Razor and Entity Framework. I am now working on the Comment section.

I am using the following table for comments.

My Comment table

Here I am using the ‘CommentParent’ column and setting it a value of an another ‘CommentID’ if a user is replying to a comment, else I have set a value of null.

Problem

I am using the following code to display comments,

@foreach (var comment in Model.Comments)
{
    <div>
        @comment.CommentContent
    </div>
    <br />
}

I am not sure how to display the “replyTo” comments as shown in the image below…
enter image description here
Please can anyone guide me as how this can be done…

  • 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-08T14:49:51+00:00Added an answer on June 8, 2026 at 2:49 pm

    First You will have to change your Model Class, Lets suppose your model class is :

    public class CommentsModel
    {
         Public Int64 CommentId {get;set;}
         ....
         ....
         //Introduce a new property in it as:
         Public CommentsModel[] ChildComments {get;set;}
    }
    

    This new property will hold the child comments of a specific comment up to N Level. Than in your View you can do it like:

    @foreach (var comment in Model.Comments)
    {
        <div>
        @comment.CommentContent
        </div>
        <br />
        @if(comment.ChildComments.Length > 0)
        {
            // Display Level 1 Comments and so on and so far
        }
    }
    

    You can manage the lookout of comments by using Css Class on Divs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with MVC 3, Razor and Entity Framework. I am making a
I am using the code at http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/comment-page-1/#comment-14326 for building custom view. I wanted to
Following ROR's guides getting started tutorial , I am making a blog having two
Im making a mysql table which will be holding my blog posts and some
I'm trying to get this working: http://drwpf.com/blog/2009/03/17/tips-and-tricks-making-value-converters-more-accessible-in-markup/ I took code from comments where we
I'm considering making something similar to Failblog using Django. That is, a blog where
I am making an application for online blog I am using JqueryMobile features to
I'm making my personal blog using Flask. The blog will use static files for
I am using MVC 3 and Razor View engine. What I am trying to
i'm just started making blog via RoR, using blog-from-scratch guide and i've got some

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.