views:

113

answers:

1

This has been a fun week (if you look back at my questions you'll see a common theme).

I have a repeater that is bound to a collection. Each repeater item dynamic control that corresponds to the collection item, it also renders out a header over each control that contains a Delete link.

When the delete link is clicked, the appropriate item is removed from the collection, and the repeater is rebound.

The problem I am encountering is that once I alter the repeater items, the state on some of the usercontrols is lost. Its always the same controls, regardless of where they are in the collection.

I'm wondering if changing the bound collection is a no-no, and it may confuse viewstate from properly restoring the values.

Can anyone clarify? How else can I do this?

+2  A: 

Ok, answered my own question.

The answer is, don't...its a nightmare.

Instead, I added a softDelete flag, and instead of removing the item from the collection, I just set this flag. Then, the repeater does not render items are marked for deletion.

When the collection is saved, it discards the items marked for deletion, and saves...

Everything is fixed, if not in an odd way.

FlySwat