I have some problems with the rather complicated Table and Razor tags.
I took "@". (ex before if, etc.).
I played for about 30 minutes and I canβt find a way to do this. I always get the error that / or similiar does not have a closing tag. I played with @: etc., but just can't get it.
If someone can help me, and if someone can give a decent explanation for the @: tag, I would really appreciate it.
<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 those 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>
source share