473,406 Members | 2,769 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,406 software developers and data experts.

Repeater and Custom HTML Question

> Hello,

How to control the structure of the HTML inside of the ItemTemplate of the
Repeater?

For example, if a certain data column value is empty (or contains some
specific string or number), I want to be able to "hide" a part of the HTML
of the ItemTemplate.

Say a customer has phone number and extension. The extension is optional.
When the extension is there, the phone should be displayed in this format: 123-555-6789 Ext: 123

If there is no extension, the phone should be simply: 123-555-6789.

I have the following ItemTemplate:

<ItemTemplate>
<tr>
<td>Phone:
<%#DataBinder.Eval(Container.DataItem,"phone")%>-x<%#DataBinder.Eval(Contain er.DataItem,"extension")</td>
</tr>
</ItemTemplate>

However, this will produce an undesirable output if there is no extension:
123-555-6788 Ext:

What is the most appropriate way to avoid this? An example would be great!

I am sure may people have come across this, since it is very common to have "very dynamic" HTML output that is dependent on the values of the data that is bound to the Repeater control.

Thanks,
Arsen

Nov 15 '05 #1
1 2722
Hello,

You can probably put the extension in a separate server-side div (or panel)
and bind the div's Visible property to something like

<%# DataBinder.Eval(Container.DataItem,"extension").To String().Length > 0 %>

I am not an ASP .NET expert though so I cannot be sure this will work out
:-(

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Arsen V." <ar****@hotmail.com> wrote in message
news:uB**************@TK2MSFTNGP11.phx.gbl...
Hello,

How to control the structure of the HTML inside of the ItemTemplate of the Repeater?

For example, if a certain data column value is empty (or contains some
specific string or number), I want to be able to "hide" a part of the HTML of the ItemTemplate.

Say a customer has phone number and extension. The extension is optional. When the extension is there, the phone should be displayed in this

format:
123-555-6789 Ext: 123

If there is no extension, the phone should be simply: 123-555-6789.

I have the following ItemTemplate:

<ItemTemplate>
<tr>
<td>Phone:

<%#DataBinder.Eval(Container.DataItem,"phone")%>-x<%#DataBinder.Eval(Contain
er.DataItem,"extension")</td>
</tr>
</ItemTemplate>

However, this will produce an undesirable output if there is no extension: 123-555-6788 Ext:

What is the most appropriate way to avoid this? An example would be great!
I am sure may people have come across this, since it is very common to

have
"very dynamic" HTML output that is dependent on the values of the data

that
is bound to the Repeater control.

Thanks,
Arsen



Nov 15 '05 #2

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

Similar topics

1
by: Arsen V. | last post by:
Hello, How to control the structure of the HTML inside of the ItemTemplate of the Repeater? For example, if a certain data column value is empty (or contains some specific string or number),...
3
by: Mark | last post by:
I am looking for an example of using checkboxes in a repeater control where the checkbox state is persisted from page to page. Thank you, Mark
2
by: Antoine | last post by:
I would like to construct my own list of items in a grid/ table/ item list layout but I have a problem. I want to add a sort of index row based on time, such as there might be blank values. Sure...
3
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
3
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
5
by: Brad Baker | last post by:
I am trying to make a "tabbed" interface by iterating through a dataset with a conditional statement. For example: ...
0
by: Murdz | last post by:
Hello. I have created a set of custom controls to spit out XML for a IVVR platform. This all works well; however there are instances I want to loop through an iteration spitting out chucks of XML...
12
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have no experience using the repeater control. I have a user control I've created with multiple properties. I've created a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.