how to show predefined text instrad of value in Repeater.

G

George Ter-Saakov

Hi. I am trying to show the grid of prices.
But if there is no price I want to show "NA". How can I do that?

Here is the code I am using to display the grid.

<asp:Repeater id=Repeater1 runat="server">
<ItemTemplate>
<tr>
<td width="30%" align="center" nowrap class="btext"><%# ((clsModifier)Container.DataItem).Price.ToString("$#,##0.00")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>


Thanks.
George.
 
K

Ken Cox [Microsoft MVP]

Hi George,

How about inserting an IIF in there as you evaluate the item?

<table>
<asp:repeater id=Repeater1 runat="server">
<itemtemplate>
<tr>
<td width="30%" align="center" nowrap ><%#
iif(DataBinder.Eval(Container.DataItem, "UnitPrice")=0,"NA",
format(DataBinder.Eval(Container.DataItem, "UnitPrice"),"$#,##0.00") )%>

</td>
</tr>
</itemtemplate>
</asp:repeater> </table>

Does this help?

Ken
MVP [ASP.NET]


Hi. I am trying to show the grid of prices.
But if there is no price I want to show "NA". How can I do that?

Here is the code I am using to display the grid.

<asp:Repeater id=Repeater1 runat="server">
<ItemTemplate>
<tr>
<td width="30%" align="center" nowrap class="btext"><%#
((clsModifier)Container.DataItem).Price.ToString("$#,##0.00")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>


Thanks.
George.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top