mvc core 2.0 ile telefon format (string.format ile)


*** Önemli not : telefon field genellikle veritabanında string olur ama gördüğüm kadarıyla bunun çalışması için int e convert edilmesi gerekiyor.

<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.CompanyName)
</th>
<th>
  @Html.DisplayNameFor(model => model.Phone )
  </th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CompanyName)
</td>
<td>
@String.Format("{0: (###) ###-####}",Convert.ToInt64( item.Phone))
@*@Html.DisplayFor(modelItem => item.Phone)*@
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.ShipperID">Edit</a> |
<a asp-action="Details" asp-route-id="@item.ShipperID">Details</a> |
<a asp-action="Delete" asp-route-id="@item.ShipperID">Delete</a>
</td>
</tr>
}
</tbody>
</table>

Yorumlar