在 aspx 页面中:
<asp:ListView ID="ListViewPosts" ItemType="Post"
SelectMethod="ListViewPosts_GetData" runat="server"
OnItemDataBound="ListViewPosts_ItemDataBound">
...
...
</asp:ListView>
后面的代码:
protected void ListViewPosts_ItemDataBound(object sender, ListViewItemEventArgs e)
{
...
Post p = Item; //where Item stands for the current Post record in ListView.
...
}
如果我有这个ListView
在哪里ItemType="Post"
;Post
是一个数据库表。如何在代码隐藏方法中访问Item
(代表表中的当前记录)的当前值Post
ListViewPosts_ItemDataBound