String problem

  • Thread starter Thread starter Eugene Anthony
  • Start date Start date
E

Eugene Anthony

I am using the following statement in my repeater control.

<%# "if(" + int.Parse(Eval("RegistrationID").ToString()) + "!=" +
int.Parse(Session["id"].ToString()) + "{<a
href=SubscriptionCart.aspx?GroupID=" + Eval("RegistrationID") +
">Subscribe</a>}" %>

The problem is it appears as:

if(1!=1{Subscribe}


How do I solve the problem?

Eugene Anthony
 
Eugene said:
I am using the following statement in my repeater control.

<%# "if(" + int.Parse(Eval("RegistrationID").ToString()) + "!=" +
int.Parse(Session["id"].ToString()) + "{<a
href=SubscriptionCart.aspx?GroupID=" + Eval("RegistrationID") +
">Subscribe</a>}" %>

The problem is it appears as:

if(1!=1{Subscribe}

How do I solve the problem?

What problem? That is exactly what the code that you have written will
display.

You have strings that contains what looks like program code. If you
intended to execute the code instead of displaying it, you should not
put it inside strings.
 
I am using the following statement in my repeater control.

<%# "if(" + int.Parse(Eval("RegistrationID").ToString()) + "!=" +
int.Parse(Session["id"].ToString()) + "{<a
href=SubscriptionCart.aspx?GroupID=" + Eval("RegistrationID") +
">Subscribe</a>}" %>

To compare a number inline within the repeater you should use
following syntax

<%# ((int)(Eval("num1"))> 111 ? Eval("num1") : Eval("num2"))%>

What do you mean by "1{Subscribe}"?
 
Back
Top