views:

326

answers:

3

Before I do this I figured I would ask if it was the best way. Each "Vendor" object has a "Bucket" object. In my repeater I need to display some properties from Vendor and some from Bucket, also some images populated by FileSystem that are linked to the vendor. I figured the best way to do this is bind the repeater with the vendor object, then on ItemDataBound I would populate the images and the buckets based on the vendor that is bound to that particular Items[e.Item.ItemIndex].

Is this the best way to go about this? Thanks.

+2  A: 

That is how I usually go about it, bind on the main object and deal with the details in the ItemDataBound.

Kevin Sheffield
What would be the best way to handle hte ajax call if you were going to only display vendors and have the buckets show up when a vendor was clicked? an update panel in your itemtemplate and binding a nested repeater in itemcommand event?
Chris Westbrook
+2  A: 

If the Vendor object can only hold a single Bucket object it may be appropriate to bind it all in a single, top-level repeater. You can access the Bucket through simple data-binding all at the top level without overriding ItemDataBound.

Because you're most likely binding the "Vendor", you have access to it's members in a databind if you want to do it this way:

<%# DataBinder.Eval (Container.DataItem, "Bucket.Property" ) %>

You want to do the ItemDataBound if you must "process something" during each iteration of the binding and need detailed access to each Vendor object for decision making.

If the Vendor object can hold multiple Buckets, then the best way to get access to that is through ItemDataBound. On each iteration of the Vendor you could bind a new, nested repeater to display the bucket data, or perform whatever repeating/aggregation functionality you may need.

Depending on how you want it to behave at your client, you could render the Vendors only. When the user clicks on the Vendor (or whatever), you could perform an AJAX call to the server which would retrieve the Bucket data and render it into your page dynamically. You may want to try that approach if there are a large number of vendors along with their buckets being rendered. This would help database performance, and page render time in contrast to building it all on the ASPX server side. (But this would need to be a lot of data, you should do it for usability/client reasons before trying to merit performance gains.)

Aaron
A: 

I'm sorry, I should have been more clear, each vendor has multiple buckets.

Sara Chipps
sounds like a repeater inside a repeater?
Kevin Sheffield
I was more thinking a listbox inside a repeater, since the buckets will be displayed based on a boolean isPopulated.
Sara Chipps