Tuesday, March 21, 2006

There has to be an easier way...

I am working on a C# application in .NET 1.1. I have a Repeater web control to which I bind an IList of objects. Upon postback I need to know the ID of the object that I bound so that can associate the data with the correct object. I went down a lot of dead ends first but eventually I stumbled upon this solution.

I created an event handler for the ItemDataBound event of the Repeater where I added the UniqueID of each control to a Hashtable. After all of the items were bound (PreRender event of the repeater) I stored the Hashtable in Viewstate. After postback I retrieve the Hashtable from Viewstate and look up the UniqueID of each RepeaterItem.

This is a relatively simple approach to reproduce but it seems like a lot of work and that the framework should be able to help me more. Any ideas?


Post a Comment

<< Home