Reputation: 291
Hello everyone I'm trying to display my array's values in my View but there is something wrong at my foreach loop cause there is no output in my View could you help me?
@model icerik.TahakkukServices.MakbuzList
@using icerik.TahakkukServices
@{
ViewBag.Title = "Deneme";
Layout = "~/Views/Shared/_Layout5.cshtml";
}
@{
TahakkukServicesClient client = new TahakkukServicesClient();
client.ClientCredentials.UserName.UserName = "service_test";
client.ClientCredentials.UserName.Password = "...";
client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
MakbuzList[] liste = client.GetMakbuzListe(2);
}
@foreach (var item in liste)
{
Html.Display(item.Adi);
}
Upvotes: 2
Views: 2157
Reputation: 17176
Don't be afraid to use html markup. You can display it however you want. For example like table
<table>
@foreach (var item in liste)
{
<tr>
<td>
@item.Adi
</td>
</tr>
}
</table>
or list
<ul>
@foreach (var item in liste)
{
<li>
@item.Adi
</li>
}
</ul>
Upvotes: 1
Reputation: 139758
You need put a @
before your Html.Display
to make the generated html written to the output:
Also if you need to display a strongly typed property value use the DisplayFor
method instead:
@foreach (var item in liste)
{
@Html.DisplayFor(m => item.Adi)
}
Here is a quickreference about the razor syntax.
Upvotes: 1