0

Hello friends I want to list my array and my datas come from Web Service so I can't use Html.DisplayFor(model=>model.) here is my code at view

@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.DisplayFor(item.Adi) 

                }
Furkan Sönmez
  • 73
  • 1
  • 13

2 Answers2

0

This is similiar to this question: What is the @Html.DisplayFor syntax for? You need to create a display template for whatever type .Adi is.

Community
  • 1
  • 1
John Sobolewski
  • 4,512
  • 1
  • 20
  • 26
0

First you should not do a web service call from a view. I think may be you are doing for testing. I would suggest you to create a BL class that takes care of the service invocation and most importantly I would strongly recommend you to create a view model class that will copy the properties you needed to display in the views.

Don't directly use the entities returned by web service in views and it's really bad. As I said create the view model and create the necessary properties that you needed to use in the view. In complex cases you could use tools like AutoMapper to map the properties between the webservice entities and your view models.

VJAI
  • 32,167
  • 23
  • 102
  • 164