如何访问的ListView OnItemDataBound方法的当前项目的ItemType值? [英] How to access the current ItemType Item value from OnItemDataBound method of ListView?
本文介绍了如何访问的ListView OnItemDataBound方法的当前项目的ItemType值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在aspx页面:
<asp:ListView ID="ListViewPosts" ItemType="Post"
SelectMethod="ListViewPosts_GetData" runat="server"
OnItemDataBound="ListViewPosts_ItemDataBound">
...
...
</asp:ListView>
背后code:
protected void ListViewPosts_ItemDataBound(object sender, ListViewItemEventArgs e)
{
...
Post p = Item; //where Item stands for the current Post record in ListView.
...
}
如果我有这样的的ListView
其中的ItemType =邮报
; 发表
是一个数据库表。
如何在$ c使用项目
(表示从发表
表中当前记录)的当前值后面的方法$ C ListViewPosts_ItemDataBound
If I have this ListView
where in ItemType="Post"
; Post
is a database table.
How to access the current value of Item
(which stands for the current record from thePost
table) in the code behind method ListViewPosts_ItemDataBound
推荐答案
试试这个:
请注意,发表应的DataRow 如果发表是表。
protected void ListViewPosts_ItemDataBound(object sender, ListViewItemEventArgs e)
{
...
DataRow p = (DataRow)e.Item.DataItem; //where Item stands for the current Post record in ListView.
...
}
这篇关于如何访问的ListView OnItemDataBound方法的当前项目的ItemType值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文