我是新來的asp.net(webforms)。我按照這個教程 - >http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/ui_and_navigationListView項綁定不起作用
在我如教程中描述添加以下代碼的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。這是爲什麼?