By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

LoadTemplate And ItemCreated Event

P: n/a

I'm going to display data with a repeater control, and each row can have
a different layout depending on the value of a column: for example, if
column A contains value "1" I want to display Column B; but if column A
contains value "2", I'm going to display column C and D. (real situation
is a bit more complicated, of course).
I've been searching around in the past few days trying to get experiences
from others having similar problems, but didn't find an easy and clean

As a final test, I simply try the following:

1. Create different controls for the different layouts
2. Load the appropriate template for each row in ItemCreated event
handler, using something like (rp is the repeater control)

Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)

Select Case CType(row.Item("Group"), String)
Case "01"
rp.ItemTemplate = LoadTemplate("row05.ascx")
Case "02"
rp.ItemTemplate = LoadTemplate("row03.ascx")
Case Else
rp.ItemTemplate = LoadTemplate("row06.ascx")
End Select
The above code seems to work without problems, but I suppose there is
something wrong, since no one has ever mentioned such a trivial solution.

So the question is: which is the drawback of this solution? What's wrong?

Jun 12 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.