Repeater and Custom HTML Question

  • Thread starter Thread starter Arsen V.
  • Start date Start date
A

Arsen V.

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:
 
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").ToString().Length > 0 %>

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