【发布时间】:2013-07-17 09:46:30
【问题描述】:
我是 asp.net(webforms) 的新手。我按照本教程进行操作 --> http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/ui_and_navigation
在 Site.Master 中,我按照教程中的说明添加了以下代码:
<section style="text-align: center; background-color: #fff">
<asp:ListView ID="categoryList"
ItemType="VanchoWorks.Models.Category"
runat="server"
SelectionMethod="GetCategories" >
<ItemTemplate>
<b style="font-size: large; font-style: normal">
<a href="/ProductList.aspx?id=<%#: Item.CategoryID %>">
<%#: Item.CategoryName %>
</a>
</b>
</ItemTemplate>
<ItemSeparatorTemplate> - </ItemSeparatorTemplate>
</asp:ListView>
</section>
在代码隐藏中(Site.Master.cs)
public IQueryable<Category> GetCategories()
{
var db = new ProductContext();
IQueryable<Category> query = db.Categories;
return query;
}
但是当我运行应用程序时没有显示 ListView 的迹象。我在 GetCategories() 第 1 行添加了断点,但它并没有停在那里,这让我觉得我没有很好地设置 SelectionMethod。这是为什么呢?
【问题讨论】:
标签: asp.net listview binding webforms