Sunday 9 September 2007

Customising Repeater ItemTemplate output

1. Creating a Order Confirmation page

This page has to look up information from various tables e.g Orders, OrderDetails, Contacts and then populate the relevant objects within the application.

Once this is done, a repeater control is used to display the details of each product the user has ordered.

Depending on the type of product, the rendering of each item needs to be tailored. For example, Memberships need to display the names of each person associated with that membership application as well as a barcode which represents the unique membership id.

Originally i thought of customising the repeater control in order to achieve the custom display for each product type but in the end, i simply re-populated the OrderDetails object with all the details from OrderDetails table and then bound the repeater control to the Products list of OrderDetails.

Utilising the OnItemDataBound event, I was able to achieve different HTML output depending on ProductType by testing the ProductCategoryID against the know product types and then calling a specific RenderProduct method which would set the InnerHTML property of the DIV element that was present within the ItemTemplate for the Repeater control.

Specific details of implementation to follow...

No comments:

Post a Comment