Repeater question

M

M.D.M.

Hi,

I display ads via repeater - name, address, text, anonymous (yes or no)
etc.. Repeater values are loaded from database. If ad is not anonymous I want
to display everything but if it is anonymous I need display completely other
structure - only text and before it header anonymous.

E.g.
Name1, Address1 // Not anonymous ad
Link to other ads from this person
Text1

This is anonymous ad // Anonymous ad
Text1a

Name2, Address2 // Not anonymous ad
Link to other ads from this person
Text2

Name3, Address3 // Not anonymous ad
Link to other ads from this person
Text3

Is it possible to make it in repeater ? Can I have 2 different templates to
use in repeater ?
(I can't display it using 2 different repeaters because they are sorted by
date)

Thank you
 
S

Steven Cheng[MSFT]

Hi Madar,

Welcome to ASPNET newsgroup.
As for the problem on dynamically using different template depend on the
datasource item's value in repeater control, based on my experience, the
buildin asp.net template databound controls (repeater, datalist....) don't
support this. If we really need to perform such work, we can achieve this
through creating our own custom Repeater template control and define the
databinding logic. In addition, I've also seen some community guys who
creating custom wrapper control to perform such works, here is a tech
article in code project:

#A Templated databound Repeater control with per-row template selection
http://www.codeproject.com/aspnet/ObjectRepeater.asp#xx960299xx

In my opinion, I'd rather suggest you try creating a custom template
databound control and just choose template in your control's
CreateChildControls period. This will make things easier as the above
article means (but will have less reusability). For detailed reference on
creating custom template databound control, you can refer to the following
msdn reference;

#Templated Data-Bound Control Sample
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcontemplateddatabound
controlsample.asp?frame=true

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)










A Templated databound Repeater control with per-row template selection
--------------------
| Thread-Topic: Repeater question
| thread-index: AcWMdQ2BLxWucdISQiefa3h5c73qnQ==
| X-WBNR-Posting-Host: 194.212.229.226
| From: =?Utf-8?B?TS5ELk0u?= <[email protected]>
| Subject: Repeater question
| Date: Tue, 19 Jul 2005 08:18:01 -0700
| Lines: 29
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:9989
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Hi,
|
| I display ads via repeater - name, address, text, anonymous (yes or no)
| etc.. Repeater values are loaded from database. If ad is not anonymous I
want
| to display everything but if it is anonymous I need display completely
other
| structure - only text and before it header anonymous.
|
| E.g.
| Name1, Address1 // Not anonymous ad
| Link to other ads from this person
| Text1
|
| This is anonymous ad // Anonymous ad
| Text1a
|
| Name2, Address2 // Not anonymous ad
| Link to other ads from this person
| Text2
|
| Name3, Address3 // Not anonymous ad
| Link to other ads from this person
| Text3
|
| Is it possible to make it in repeater ? Can I have 2 different templates
to
| use in repeater ?
| (I can't display it using 2 different repeaters because they are sorted
by
| date)
|
| Thank you
|
 
S

Steven Cheng[MSFT]

Hi Madar,

Have you got any further progress on this issue and is the suggestions in
my last reply somewhat helps? If there're anything else we can help, please
feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| X-Tomcat-ID: 42653231
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Wed, 20 Jul 2005 02:33:27 GMT
| Subject: RE: Repeater question
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| Lines: 85
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:9996
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Madar,
|
| Welcome to ASPNET newsgroup.
| As for the problem on dynamically using different template depend on the
| datasource item's value in repeater control, based on my experience, the
| buildin asp.net template databound controls (repeater, datalist....)
don't
| support this. If we really need to perform such work, we can achieve this
| through creating our own custom Repeater template control and define the
| databinding logic. In addition, I've also seen some community guys who
| creating custom wrapper control to perform such works, here is a tech
| article in code project:
|
| #A Templated databound Repeater control with per-row template selection
| http://www.codeproject.com/aspnet/ObjectRepeater.asp#xx960299xx
|
| In my opinion, I'd rather suggest you try creating a custom template
| databound control and just choose template in your control's
| CreateChildControls period. This will make things easier as the above
| article means (but will have less reusability). For detailed reference on
| creating custom template databound control, you can refer to the
following
| msdn reference;
|
| #Templated Data-Bound Control Sample
|
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcontemplateddatabound
| controlsample.asp?frame=true
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
|
|
|
|
|
| A Templated databound Repeater control with per-row template selection
| --------------------
| | Thread-Topic: Repeater question
| | thread-index: AcWMdQ2BLxWucdISQiefa3h5c73qnQ==
| | X-WBNR-Posting-Host: 194.212.229.226
| | From: =?Utf-8?B?TS5ELk0u?= <[email protected]>
| | Subject: Repeater question
| | Date: Tue, 19 Jul 2005 08:18:01 -0700
| | Lines: 29
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontrols:9989
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| |
| | Hi,
| |
| | I display ads via repeater - name, address, text, anonymous (yes or no)
| | etc.. Repeater values are loaded from database. If ad is not anonymous
I
| want
| | to display everything but if it is anonymous I need display completely
| other
| | structure - only text and before it header anonymous.
| |
| | E.g.
| | Name1, Address1 // Not anonymous ad
| | Link to other ads from this person
| | Text1
| |
| | This is anonymous ad // Anonymous ad
| | Text1a
| |
| | Name2, Address2 // Not anonymous ad
| | Link to other ads from this person
| | Text2
| |
| | Name3, Address3 // Not anonymous ad
| | Link to other ads from this person
| | Text3
| |
| | Is it possible to make it in repeater ? Can I have 2 different
templates
| to
| | use in repeater ?
| | (I can't display it using 2 different repeaters because they are sorted
| by
| | date)
| |
| | Thank you
| |
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top