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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:30:15+00:00 2026-06-17T18:30:15+00:00

I have a simple relationship for a conference site where I have multiple time

  • 0

I have a simple relationship for a conference site where I have multiple time slots and I want to display multiple sessions in each time slot.

The code below works correctly, however I’ve had to use @Html.Raw(“..”) in the outer code block. If I just try to put raw html (like ABCD right above the first @Html.Raw(“”) I get a compiler error. I’m pretty new to razor and just don’t get how I can make my life simpler and have real html code in the nested foreach and not have to have everything wrapped in a helper method.

thanks.

    @Html.Raw("<table id='myTable' border='1'>")

    @foreach (var sessionTime in Model.SessionsByTime)
    { 
        @Html.Raw("<tr>")
        @Html.Raw("<td>")
        @sessionTime.StartTimeFriendly
        @Html.Raw("</td>")
        @Html.Raw("<td></td>")
        @Html.Raw("</tr>")

        @Html.Raw("<table>")
            foreach (var session in sessionTime.sessionsResults)
            {
            <tr>
                <td width="300"></td>
                <td width="300">@session.Title</td>
            </tr>
            }
        @Html.Raw("</table>")
    }
  • 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-17T18:30:17+00:00Added an answer on June 17, 2026 at 6:30 pm

    This should look like thid

    <table id='myTable' border='1'>
    @foreach (var sessionTime in Model.SessionsByTime)
    { 
        <tr>
          <td>@sessionTime.StartTimeFriendly</td>
          <td></td>
        </tr>
        <table>
            @foreach (var session in sessionTime.sessionsResults)
            {
            <tr>
                <td width="300"></td>
                <td width="300">@session.Title</td>
            </tr>
            }
        </table>
    }
    </table>
    

    if you need to diplay some text that is not wrapped in an html tag you need to use @::

    @foreach(var s in list) {
        @: hello there @s
        <text>this also work instead of @: and is usuful
        when you need more than one line
        </text>
    }
    

    if you are inside a code block and not inside an html tag, Razor will assume that you are just writing code that’s why @: or <text> is needed

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

Sidebar

Related Questions

I have a simple relationship Questionnaire has_many Answers I have multiple questionnaires. I want
I have a simple has_many belongs_to relationship and I want to include the parent
I have two simple classes which reference each other as a one-to-many relationship defined
I have some simple Code First classes with a Many to One relationship. If
I have a simple relationship. A campaign is linked to two Pages. A page
I have a simple has_one/belongs_to relationship between two models. This is a new association
I have a simple one-to-many relationship. I would like to select rows from the
I have a fairly simple foreign key relationship displayed by an inline in Django's
I'm getting started with FubuMVC and I have a simple Customer -> Order relationship
I have a simple Book Author relationship class Author(models.Model): first_name = models.CharField(max_length=125) last_name =

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.