Inline Evaluation of a DataBound Value within a Repeater Item Template

M

Michael Wendel

Ok. I have been banging my head against the wall trying to figure out
how this piece of display logic can be implemented:

<% if (DataBinder.Eval(Container.DataItem, "SomeItem") != "SomeValue")
{ %>
HTML DISPLAY BLOCK
<% } %>

The reason I would prefer to do it this way is:
(1) Easier management by the HTML producers/designers
(2) It seems pointless to create yet another control for a single
table row or even table cell depending upon the case of HTML formatted
data.

In the future I won't need this but I am dealing with a pre-existing
code base that I don't have the time to change.
 
C

Craig Deelsnyder

Ok. I have been banging my head against the wall trying to figure out
how this piece of display logic can be implemented:

<% if (DataBinder.Eval(Container.DataItem, "SomeItem") != "SomeValue")
{ %>
HTML DISPLAY BLOCK
<% } %>

The reason I would prefer to do it this way is:
(1) Easier management by the HTML producers/designers
(2) It seems pointless to create yet another control for a single
table row or even table cell depending upon the case of HTML formatted
data.

In the future I won't need this but I am dealing with a pre-existing
code base that I don't have the time to change.

wrap the HTML block in a asp:panel or a similar container control, set its
Visible property to a databound expression that is your If expression

<asp:panel ... Visible='<%# DataBinder.Eval(Container.DataItem,
"SomeItem") != "SomeValue" %>' ...>
HTML DISPLAY BLOCK
</asp:panel>

I belive this should work...regardless, the DataBinder.Eval only makes
sense inside of a binding statement/expression, not in a script block...
 
M

Michael Wendel

I'll check it out.

Thanks,

Michael


wrap the HTML block in a asp:panel or a similar container control, set its
Visible property to a databound expression that is your If expression

<asp:panel ... Visible='<%# DataBinder.Eval(Container.DataItem,
"SomeItem") != "SomeValue" %>' ...>
HTML DISPLAY BLOCK
</asp:panel>

I belive this should work...regardless, the DataBinder.Eval only makes
sense inside of a binding statement/expression, not in a script block...
 

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,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top