开发者

ListView ItemDataBound - determine if item is AlternatingItem?

开发者 https://www.devze.com 2022-12-08 14:27 出处:网络
I\'m using the Listview to display my data. On the ItemDatabound event I want to do some manipulation and change some of the data being displayed. When I check the Item on this event I am using the fo

I'm using the Listview to display my data. On the ItemDatabound event I want to do some manipulation and change some of the data being displayed. When I check the Item on this event I am using the following code, But I need to know 开发者_如何学Goif the item is an alternating item as this will effect what I want to do with the row. Can anyone point me in the right direction?

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

   //Do something   
}


see if this works:

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

精彩评论

暂无评论...
验证码 换一张
取 消