如何在repeater项目命令中获取下一个和上一个行值?

时间:2013-05-31 13:40:00

标签: asp.net repeater

有没有办法在转发器的Item_Command事件中获取转发器的下一行或上一行值?

1 个答案:

答案 0 :(得分:1)

在Item_Command处理程序中尝试这样的事情:

Button senderButton = (Button)sender;
RepeaterItem currentRepeaterItem = (RepeaterItem)(senderButton.NamingContainer);
int currentRepeaterItemIndex = currentRepeaterItem.ItemIndex;

RepeaterItem previousRepeaterItem = MyRepeater.Items[currentRepeaterItemIndex-1];
RepeaterItem nextRepeaterItem = MyRepeater.Items[currentRepeaterItemIndex+1];