How to make the text appear in a new line in a table

0

I'm working with mvc, but when I show a table it appears like this link

This is my view

<table class="table">
<tr>
    @for (int i = 0; i < Methods.CurrentTable.GetColumns().Count(); i++)
    {

        <th>
        @Html.DisplayTextFor(item => Methods.CurrentTable.GetColumns()[i].ColumnName)    
        </th>
     }
</tr>   
<tr> 
   @for (int i = 0; i < Methods.Rows.Count(); i++)
   {
       for (int m = 0; m < Methods.Rows[i].Registers.Count(); m++)
       {
           if (Methods.Rows[i].Registers[m] != "")
           {
            <td>
                @Html.DisplayTextFor(x => Methods.Rows[i].Registers[m])<br />

            </td>
           }
       }
   }
    </tr>
</table>
    
asked by Luis Ortiz 03.08.2018 в 23:54
source

1 answer

1

You have to place the <tr> in the first for asi:

<table class="table">
<tr>
    @for (int i = 0; i < Methods.CurrentTable.GetColumns().Count(); i++)
    {

        <th>
        @Html.DisplayTextFor(item => Methods.CurrentTable.GetColumns()[i].ColumnName)    
        </th>
     }
</tr>   

   @for (int i = 0; i < Methods.Rows.Count(); i++)
   {
       <tr>
       for (int m = 0; m < Methods.Rows[i].Registers.Count(); m++)
       {
           if (Methods.Rows[i].Registers[m] != "")
           {
            <td>
                @Html.DisplayTextFor(x => Methods.Rows[i].Registers[m])<br />

            </td>
           }
       }
       </tr>
   }

</table>
    
answered by 03.08.2018 в 23:57