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

  • Home
  • SEARCH
  • 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 8401011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:41:49+00:00 2026-06-09T21:41:49+00:00

I have some issues with a rather complex Table and Razor Tags. I took

  • 0

I have some issues with a rather complex Table and Razor Tags.

I took the Most “@” out. (e.x. in front of the if etc.).

I played around for around 30 min and i can’t seem to find the way to do it. I will always get error that / or similiar does not have any closing Tag. I played around with @: etc. but just can’t get it.

If someone could help me out, and if someone could give a decent explanation of the @: tag, i’d highly appreciate that.

<div>
    if (Model.dsInfoUser.Tables[0].Rows.Count != 0)
    {
        <table>
            for (int i = 0; i < Model.dsInfoUser.Tables[0].Rows.Count; i++)
            {
                if (i % 2 == 1)
                {
                    <tr class="tableEven">
                }
                else
                {
                    <tr class="tableOdd">
                }
                    @*Picture*@
                    if (i == 0)
                    {
                        <td rowspan="@Model.dsInfoUser.Tables[0].Rows.Count" class="tblPicture"><img src="@Model.dsInfoUser.Tables[0].Rows[i][1]" /></td>
                    }
                    <td>
                        @Model.dsInfoUser.Tables[0].Rows[i][0].ToString()
                    </td> 
                    <td>
                        @Model.dsInfoUser.Tables[0].Rows[i][1].ToString()
                    </td> 
                </tr> 
                if (i == 5)
                {
                    <tr>
                        <td>
                            <text>Member Of:</text>
                        </td>
                            <td>
                                <table>
                                    for (int j = 0; j < Model.dsInfoUser.Tables[1].Rows.Count; j++)
                                    {
                                    if (j % 2 == 1)
                                    {
                                        <tr class="tableEven">
                                    }
                                    else
                                    {
                                        <tr class="tableOdd">
                                    }
                                        <td rowspan="3">
                                            <div style="width: 400px; overflow-y: scroll">

                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                    </tr>
                }
        </table>
    }
</div>

For anyone who would like to know, here is the fixed version:

<div>
    @if (Model.dsInfoUser.Tables[0].Rows.Count != 0)
    {
        <table>
            @for (int i = 0; i < Model.dsInfoUser.Tables[0].Rows.Count; i++)
            {
                <tr class="@(i % 2 == 1 ? "tableEven" : "tableOdd")">
                    @if (i == 0)
                    {
                        <td rowspan="@Model.dsInfoUser.Tables[0].Rows.Count" class="tblPicture"><img src="@Model.dsInfoUser.Tables[0].Rows[i][1]" /></td>
                    }
                    <td>
                        @Model.dsInfoUser.Tables[0].Rows[i][0].ToString()
                    </td> 
                    <td>
                        @Model.dsInfoUser.Tables[0].Rows[i][1].ToString()
                    </td> 
                </tr> 
                    if (i == 5)
                    {
                    <tr>
                        <td>
                            <text>Member Of:</text>
                        </td>
                            <td>
                                <table>
                                    @for (int j = 0; j < Model.dsInfoUser.Tables[1].Rows.Count; j++)
                                    {
                                        <tr class="@(i % 2 == 1 ? "tableEven" : "tableOdd")">
                                            <td rowspan="3">
                                                <div style="width: 400px; overflow-y: scroll">
                                                </div>
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </td>
                    </tr>
                    }
            }
        </table>
    }
</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-06-09T21:41:50+00:00Added an answer on June 9, 2026 at 9:41 pm

    You can’t do it that way. Razor expects to be properly hierarchical. In particular, this is illegal:

    if(condition)
    {
        <foo>
    }
    else
    {
        <foo>
    }
    </foo>
    

    Even though we both know that would be a well-formed <foo></foo>, razor doesn’t see it that way. It sees 2 unclosed <foo>, and a completely unrelated </foo> from nowhere.

    In your case, the way to do this is:

    <tr class="@(i % 2 == 1 ? "tableEven" : "tableOdd")">
       <td>...</td>
    </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have this rather strange issue, i am trying to line up some
I have some issues in setting the classpath for the a project for which
I have some issues with a PHP file that is not working properly. The
I have some issues with my EJB 3 timer where it is launched more
I'm have some issues adding a class to 2 navigation links on a theme.
I seems to have some issues in order to compile gproc from uwiger. I
Im starting with CoCos2d development and I think I have some issues with nodespace,
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I am integrating PayPal in my website But I have some issues in it.
I ran git pull origin and now I have some issues with merge my

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.