J
Joe Rattz
I am trying to perform some logic inside a Repeater control's template. I
need that logic dependent on the bound data. If my bound data is < 0, I
want to write one string (a CSS class), otherwise I want to write a
different string (another CSS class). Here is what I am trying to do:
<%
if(Double.Parse(DataBinder.Eval(Container.DataItem, "Amount")) < 0)
{ Response.Write("<span class=\"NewspaperCreditItemAmountN\">"); }
else
{ Response.Write("<span class=\"NewspaperCreditItemAmountP\">"); }
%>
I have formatted the code a little funky so it is easier to read. As you
can see, I want to parse the Amount field into a double and if its < 0, I
want to specify one CSS class, otherwise I want to specify a different
class.
Unfortunately, this code does not work...it doesn't like me accessing
Container this way. I can't seem to find any decent doc on this, but what
is the difference between a <% %> block and a <%# %> block (notice the #)?
I assume the Container object is a member of something. What object can I
get to the Container object from?
Any help would be appreciated. Ultimately, I am trying to change the CSS
style so the dollar amount can be red if negative, otherwise black.
Thanks.
need that logic dependent on the bound data. If my bound data is < 0, I
want to write one string (a CSS class), otherwise I want to write a
different string (another CSS class). Here is what I am trying to do:
<%
if(Double.Parse(DataBinder.Eval(Container.DataItem, "Amount")) < 0)
{ Response.Write("<span class=\"NewspaperCreditItemAmountN\">"); }
else
{ Response.Write("<span class=\"NewspaperCreditItemAmountP\">"); }
%>
I have formatted the code a little funky so it is easier to read. As you
can see, I want to parse the Amount field into a double and if its < 0, I
want to specify one CSS class, otherwise I want to specify a different
class.
Unfortunately, this code does not work...it doesn't like me accessing
Container this way. I can't seem to find any decent doc on this, but what
is the difference between a <% %> block and a <%# %> block (notice the #)?
I assume the Container object is a member of something. What object can I
get to the Container object from?
Any help would be appreciated. Ultimately, I am trying to change the CSS
style so the dollar amount can be red if negative, otherwise black.
Thanks.