473,790 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Da taItem, DataRowView)

Select Case CType(row.Item( "Group"), String)
Case "01"
rp.ItemTemplate = LoadTemplate("r ow05.ascx")
Case "02"
rp.ItemTemplate = LoadTemplate("r ow03.ascx")
...
Case Else
rp.ItemTemplate = LoadTemplate("r ow06.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 1329

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

Similar topics

3
4001
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 button nothing happens. I tried also the findcontrol method, without any result. That's the template: <asp:LinkButton ID="button1" Runat="server" Text=''
1
627
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 using the ItemDataBound event, but I don't understand why. here's a page snippet: <asp:Repeater runat="server" id="myRepeater" OnItemCreated="myRepeater_ItemCreated"> ... <ItemTemplate><tr><td><asp:Label id="myLabel" runat="server"...
9
2335
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 Integer = 0 Private Sub grd_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grd.ItemCreated
0
1019
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" cellpadding="3" cellspacing="0"> </HeaderTemplate> <FooterTemplate> </table> </FooterTemplate>
4
1954
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" OnItemCommand="RepeaterResult_Event"> <HeaderTemplate> <table width="515" border="0" cellpadding="3" cellspacing="0"> </HeaderTemplate> <FooterTemplate>
3
3322
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", "Value" Depending on the "Locked" field in the source... I want the "Value" cell to be readonly or not for each row
2
3483
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 RepeaterItemEventArgs.Item.DataItem. Does anybody know more about this strange behaviour? Thanks Philippe
2
6758
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(); addedControl.ID = "addedControl"; pagerCell.Controls.Add(addedControl);
2
2286
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 i observerd is itemcreated event is fired twice than total items present in array.
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.