473,396 Members | 1,891 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,396 software developers and data experts.

System.Web.UI.WebControls.Repeater and multiple templates

Hi,
if I create a class A with some properies, then create classes B and C
derived from A, later create and ArrayList filled with some B and C items.
This list I would like to use as a datasource for a repeater control. Is it
possible to add more than one <ItemTemplate>? I would like to have i.e two
templates, one for B and second for C object.
I'm using ASP.NET (2.0) very shortly, but I haven't discovered much about
Repeater/Datalist/Datagrid.
Thank you very much.
Robert
Nov 19 '05 #1
2 2613
Nope.
You can look at Nested Repeaters but afaik you can't have two <ItemTemplate>
sections in the same repeater.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Robert" wrote:
Hi,
if I create a class A with some properies, then create classes B and C
derived from A, later create and ArrayList filled with some B and C items.
This list I would like to use as a datasource for a repeater control. Is it
possible to add more than one <ItemTemplate>? I would like to have i.e two
templates, one for B and second for C object.
I'm using ASP.NET (2.0) very shortly, but I haven't discovered much about
Repeater/Datalist/Datagrid.
Thank you very much.
Robert

Nov 19 '05 #2
No.

What you can do is have a single item template with a placeholder

<ITemTemplate>
<asp:PlaceHolder id="content" runat="server" />
</ItemTemplate>
Then, in the ItemDataBound event, check which type your DataItem is, and
load the appropriate user control.

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
PlaceHolder content = (PlaceHolder)e.Item.FindControl("content");
if (e.Item.DataItem is B)
{
...
}else...

}

you can learn more from
http://openmymind.net/index.aspx?documentId=8#4.2

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Robert" <ro**********@atlas.cz> wrote in message
news:u3**************@tk2msftngp13.phx.gbl...
Hi,
if I create a class A with some properies, then create classes B and C
derived from A, later create and ArrayList filled with some B and C items.
This list I would like to use as a datasource for a repeater control. Is
it
possible to add more than one <ItemTemplate>? I would like to have i.e two
templates, one for B and second for C object.
I'm using ASP.NET (2.0) very shortly, but I haven't discovered much about
Repeater/Datalist/Datagrid.
Thank you very much.
Robert

Nov 19 '05 #3

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

Similar topics

0
by: Eric Diana | last post by:
I am trying to place an strings into an array of strings I am declaring as Dim Fields() As String I have another variable im doing the same thing with and it works. Public Shared Operations()...
1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
3
by: Andrew | last post by:
Hi, I am working on a questionnaire. I have displayed a questionnaire using a repeater control. The itemtemplate is as below (quite cut down): <ItemTemplate> <tr><td> <%#...
3
by: Arpan | last post by:
Consider the following code: <form runat="server"> <asp:DataList ID="dlUsers" OnCancelCommand="CancelList" OnDeleteCommand="DeleteList" OnEditCommand="EditList" OnItemCommand="ItemList"...
6
by: Doogie | last post by:
I have a Repeater control in an app I'm updating. I need to write code (event method) when a user clicks on one of the columns in the control. But there is no method like "Repeater_OnClick" or...
3
by: Emma Middlebrook | last post by:
Hi there, I've been trying to implement a repeater control in an ASP.NET 2 page but I can't seem to get the layout exactly how I want and I'm not sure if it's something that I am doing wrong or...
2
by: Nathan Sokalski | last post by:
I am write a CompositeControl, and one of the controls being included is a Repeater. This is my first time including a templated control in a control other than a UserControl. I am not sure how to...
2
by: Hong | last post by:
Hi, I have been scratching my head over this problem for hours, the repeater control I am using would only render the controls specified in HeaderTemplate and FooterTemplate, but the repeater...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.