473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

LoadTemplate And ItemCreated Event


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
solution.

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?

TIA
Jun 12 '06 #1
0 1307

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fabrizio | last post by:
Hi, I'm trying to create a page with a datalist that loads from a template the ItemTemplate, which contains a linkbutton that should have the commandname = "edit" But when I click on the link...
1
by: Kevin Hector | last post by:
Hi. Can anyone explain why, when setting the Text of a Label control in the ItemCreated event of a Repeater (example below), the Text value is NOT persisted to ViewState? I know this can be fixed by...
9
by: Manuel | last post by:
I have a Datagrid with 9 elements. The problem is that when I sort the grid by a column, it present more columns than there are. This is my code for the ItemCreated event: Private pNo As...
0
by: Antonio Carpentieri | last post by:
Hi all, in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server" OnItemCommand="RepeaterResult_Event"> <HeaderTemplate> <table width="515" border="0"...
4
by: Antonio Carpentieri | last post by:
Hi all, in my previous post I've wrong typed some tems.. this is the corrected post. in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server"...
3
by: Lars Netzel | last post by:
(applies to Windows Form .NET 2003) I'm filling a datagrid from a Datatable and applying a DataGridStyle. The Source Fields are "Name", "Value", "Locked" and the Style's Columns are "Name",...
2
by: Philippe Camus | last post by:
I didn't find any documentation about this behaviour. On postbacks the Repeater ItemCreated event is fired before Page_Load event It occurs for each item with empty...
2
by: DC | last post by:
Hi, I am doing something like this in the ItemCreated event (ASP.Net 1.1): DataGridItem pagerRow = e.Item; TableCell pagerCell = pagerRow.Cells; Control addedControl = new Control();...
2
by: archana | last post by:
Hi all, I am having one datagrid whose datasource i set as array. On itemcreated event i am having one counter which i have used to find out how many times item created event is fired. What...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.