开发者

ASP.NET MVC View with embedded code displays html out of sequence

I have a view in ASP.NET MVC. It takes the model object and iterates over a list of strings and displays them in a table row, like so:

Details

<table>
<tbody>
    <tr>
        <th>Values in the database</th>
    </tr>

<% foreach (string value in Model.lstDistinctValues)
   {%>
   <tr>

   <%=value%>
   <%} %>
   </tr>
</tbody>

The problem is that the values appear ABOVE the header. So 'Values in the database' appears at the bottom, while the va开发者_JAVA百科lues are at the top.

Why would this be happening?


You need to add TD elements.

<table>
<tbody>
    <tr>
        <th>Values in the database</th>
    </tr>

<% foreach (string value in Model.lstDistinctValues)
   {%>
   <tr>
        <td><%=value%></td>
   </tr>
   <%} %>
</tbody>
</table>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜