Reputation: 29
This is the part of the code in MVC view file cshtml. The iD is an integer number. It displays like 1 22 333, how can I make the display to 000001 000022 000333.
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.iD)
</td>
</tr>
}
Upvotes: 2
Views: 330
Reputation: 21617
You don't need the DisplayFor
use the model
@foreach (var item in Model)
{
<tr>
<td>
@item.iD.ToString("000000")
</td>
</tr>
}
Upvotes: 1