I know how to bind data to a repeater, and then modify if necessary from the Sub _ItemDataBound
But if I wanted to roll through a recordset and populate a bunch of labels in a repeater record by record, how would I go about that?
Thanks
Can you explain more about what you're attempting to accomplish? if you are parsing items in a list, why not feed them into an Enumerable collection (like List) then simply databind to that?
If the collection changes, you can always call Rebind()
I'm curious, what specific need do you have that isn't met by these options?
I have to perform various logic on the raw data before needing to populate the repeater with the results I need to display.
I could do it at the ItemDataBound level, but thought I would have more control and probably easier to run the data through logic first.
Do you know of an example I could review where you say "Enumerable collection (like List) then simply databind to that?"
Thanks
it's definitely a good idea to create the list of items you want in full, then simply feed the completed model directly to the Repeater. You can do this easily in code behind by setting the DataSource property of the Repeater to any list collection object.
Here is an example that uses ArrayList: http://www.ezineasp.net/post/ASP-Net-Binding-Repeater-ArrayList-as-DataSource.aspx
But you can use any list type source, like List
For example if you're binding a List
<%# Eval("Thing") %>
I hope this makes sense and is helpful, if you need more examples let me know and I'll try and find some more that use different types.
沒有留言:
張貼留言