How to get the next and previous row value in repe

2019-09-16 07:00发布

问题:

Is there any way to get the next or previous row value of repeater on Item_Command event of repeater?

回答1:

Try something like this... in your Item_Command handler:

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];