C# ListView ItemDataBound-确定项是否为AlternatingItem?

C# ListView ItemDataBound-确定项是否为AlternatingItem?,c#,asp.net,listview,itemdatabound,C#,Asp.net,Listview,Itemdatabound,我正在使用Listview显示我的数据。在ItemDatabound事件中,我想进行一些操作并更改正在显示的一些数据。当我检查此事件中的项目时,我使用了以下代码,但我需要知道该项目是否为交替项目,因为这将影响我想对该行执行的操作。谁能给我指出正确的方向吗 if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem currentItem = (ListViewDataItem)e.Item; DataKey

我正在使用Listview显示我的数据。在ItemDatabound事件中,我想进行一些操作并更改正在显示的一些数据。当我检查此事件中的项目时,我使用了以下代码,但我需要知道该项目是否为交替项目,因为这将影响我想对该行执行的操作。谁能给我指出正确的方向吗

if (e.Item.ItemType == ListViewItemType.DataItem)
{
   ListViewDataItem currentItem = (ListViewDataItem)e.Item;
   DataKey currentDataKey = myLilstView.DataKeys[currentItem.DataItemIndex];

   //Do something   
}
看看这是否有效:

int currentIndex = currentItem.DisplayIndex;
if (currentIndex % 2 == 1)
{
    // alternating item
}

如果此列表视图使用来自MSDN的分页,则应该使用DisplayIndex属性而不是DataItemIndex:“DisplayIndex表示数据项在当前页面中的位置,而DataItemIndex基于页面偏移量”谢谢,这非常有帮助!