Thursday, March 22, 2012

What is the correct Condition (IF...THEN) with Data Repeater ?

Hi All,

My Source Code is the following
<ItemTemplate>
<tr>
<td width="100" align="right"><font size="2" face="Verdana, Arial,
Helvetica, sans-serif"> </font></td>
<%IF #Container.DataItem("LINE53")<>2 THEN%>
<td width="300" colspan="3"><font size="2" face="Verdana, Arial,
Helvetica,
sans-serif"><b>Line <%#Container.DataItem("LINE53")%></b></font></td>
<%END IF%>
</tr>
</ItemTemplate
I got the error:
Compiler Error Message: BC30201: Expression expected.

Not uses '#'
Compiler Error Message: BC30451: Name 'Container' is not declared.

Please Help.No, you don't do it in this way. You should handle ItemDataBound event to
check the values in the data items and set the visual properties of your
template elements.

Eliyahu

<kelvinweb@.gmail.com> wrote in message
news:1142416932.080160.143950@.j52g2000cwj.googlegr oups.com...
> Hi All,
> My Source Code is the following
> <ItemTemplate>
> <tr>
> <td width="100" align="right"><font size="2" face="Verdana, Arial,
> Helvetica, sans-serif"> </font></td>
> <%IF #Container.DataItem("LINE53")<>2 THEN%>
> <td width="300" colspan="3"><font size="2" face="Verdana, Arial,
> Helvetica,
> sans-serif"><b>Line <%#Container.DataItem("LINE53")%></b></font></td>
> <%END IF%>
> </tr>
> </ItemTemplate>
> I got the error:
> Compiler Error Message: BC30201: Expression expected.
> Not uses '#'
> Compiler Error Message: BC30451: Name 'Container' is not declared.
> Please Help.
Or you can try IIf function.

HTH

Elton Wang

"kelvinweb@.gmail.com" wrote:

> Hi All,
> My Source Code is the following
> <ItemTemplate>
> <tr>
> <td width="100" align="right"><font size="2" face="Verdana, Arial,
> Helvetica, sans-serif"> </font></td>
> <%IF #Container.DataItem("LINE53")<>2 THEN%>
> <td width="300" colspan="3"><font size="2" face="Verdana, Arial,
> Helvetica,
> sans-serif"><b>Line <%#Container.DataItem("LINE53")%></b></font></td>
> <%END IF%>
> </tr>
> </ItemTemplate>
> I got the error:
> Compiler Error Message: BC30201: Expression expected.
> Not uses '#'
> Compiler Error Message: BC30451: Name 'Container' is not declared.
> Please Help.
>
Hi Eliyahu,

I don;t understand. If I want to making condition case in ItemTemplate.
How to handle it ?
Any exmples ? Urgent. Thanks
My point is that you don't make condition cases in ItemTemplate. You handle
conditions in the code.

For example, this would be a fragment of your DataItemBound event handler:

if (e.Item.DataItem as <type cast to your datasource item>)["LINE53"] <> 2)
runCodeThatWillSetTheTemplateForThisCondition();

Eliyahu

<kelvinweb@.gmail.com> wrote in message
news:1142472082.279204.27760@.j52g2000cwj.googlegro ups.com...
> Hi Eliyahu,
> I don;t understand. If I want to making condition case in ItemTemplate.
> How to handle it ?
> Any exmples ? Urgent. Thanks

0 comments:

Post a Comment