我試圖在asp.net中實現listview。但我無法得到輸出。我犯了我不知道的錯誤。請幫助我。Listview未在asp.net中顯示
我的模型
ASPX
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<div>
<asp:Table runat="server" >
<asp:TableRow>
<asp:TableCell Width="40%">
<asp:Label ID="Label17" runat="server" Font-Bold="true" Font-Size="Medium" Text='<%#Eval("RoomType") %>'></asp:Label>
</asp:TableCell>
<asp:TableCell Width="20%">
<asp:Button ID="Button1" runat="server" Text="Search" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Label ID="Label18" runat="server" Font-Bold="true" Font-Size="Medium" Text='<%#Eval("Description") %>'></asp:Label>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</ItemTemplate>
</asp:ListView>
C#
public class Place
{
public string RoomType { get; set; }
public string Description { get; set; }
}
List<Place> items = new List<Place>();
items.Add(new Place() { RoomType = "RoomType1", Description= "RoomType Description"});
items.Add(new Place() { RoomType = "RoomType2", Description = "RoomType Description" });
items.Add(new Place() { RoomType = "RoomType3", Description = "RoomType Description" });
ListView1.DataSource = items;
使用Break point進行檢查時,我發現項目列表中包含項目。但我不能進入我的頁面。
,您可以設置列表視圖的數據源? –
您需要ListView1.DataBind(); – yogi
好瑜伽,我現在解決 – Sagotharan