2012-08-31 81 views
-2

你好朋友我從Web服務獲取數據,所以我不能使用Html.DisplayFor(model => model.item)以及如何顯示數組中的數據。這裏是我的代碼:如何在MVC3中顯示數組?

@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) 
       } 
+0

這真的屬於視圖嗎? – JTMon

+0

是的,這是視圖 –

+0

可能的重複[如何在MVC3中顯示數組?](http://stackoverflow.com/questions/12214620/how-to-display-an-array-in-mvc3) – David

回答

1

@model 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(model=>model.) add your column name 
       } 
0

還好吧我知道如何做到這一點只是給型號名稱與你的服務,你可以看到在低於

@model icerik.TahakkukServices.Borc 

所以你可以使用Html.DisplayFor