2

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);



                }

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.