ASP.NET - if statement inside of a repeater, please help

Asked By S D on 14-Jan-13 02:04 PM

I have the follwoing repeater that if it is product I display diffrenbt html if it is not product but it givesme compilation error, any easy way to fix it please?

<



asp:Repeater ID="Repeater1" runat="server">




<ItemTemplate>



<%


# if (DataBinder.Eval(Container.DataItem, "CategoryCode") == "PRODUCT") { %>




<li class="module-saved-box" data-saved-id="1">




<input type="button" class="sprite close-btn">




<a href="#">




<div class="product-image">




<img src="img/products/00-large.jpg" alt="" />




</div>




<div class="caption">




<h4>Product name</h4>




<p><small>38 shades</small></p>




<p class="price">$10.99</p>




<div class="sprite rate-container">




<span class="sprite rate" style="width: 70%"></span>




<strong>(10)</strong>




</div>




</div>




</a>




</li>


<% }


else { %>




<li class="module-saved-article" data-saved-id="2">




<input type="button" class="sprite close-btn">





<a href="">




<span class="sprite article-type-text"></span>




<div data-picture class="article-more" data-alt="Article">




<div data-src="img/article-box-02-large.jpg"></div>




</div>




</a>




<div>




<a href=""><strongcontent category</strong></a>




<h4><a href="">content dscription</a></h4>




</div>




</li>


<% } %>



</ItemTemplate>




</asp:Repeater>


thanks very much


Danasegarane Arunachalam replied to S D on 14-Jan-13 09:02 PM
Try this one

<
 
  
 
  
 
asp:Repeater ID="Repeater1" runat="server">
 
  
 
  
 
  
 
<ItemTemplate>
 
  
 
  
 
<% if (DataBinder.Eval(Container.DataItem, "CategoryCode") == "PRODUCT") { %>
 
 
<li class="module-saved-box" data-saved-id="1">
  
 
<input type="button" class="sprite close-btn">
 
<a href="#">
 
  
 
  
 
  
 
<div class="product-image">
 
  
 
  
 
  
 
<img src="img/products/00-large.jpg" alt="" />
 
  
 
  
 
  
 
</div>
 
  
 
  
 
  
 
<div class="caption">
 
  
 
  
 
  
 
<h4>Product name</h4>
 
  
 
  
 
  
 
<p><small>38 shades</small></p>
 
  
 
  
 
  
 
<p class="price">$10.99</p>
 
  
 
  
 
  
 
<div class="sprite rate-container">
 
  
 
  
 
  
 
<span class="sprite rate" style="width: 70%"></span>
 
  
 
  
 
  
 
<strong>(10)</strong>
 
  
 
  
 
  
 
</div>
 
  
 
  
 
  
 
</div>
 
  
 
  
 
  
 
</a>
 
  
 
  
 
  
 
</li>
 
  
 
<% }
 
  
 
else { %>
 
  
 
  
 
  
 
<li class="module-saved-article" data-saved-id="2">
 
  
 
  
 
  
 
<input type="button" class="sprite close-btn">
 
  
 
  
 
  
 
  
 
<a href="">
 
  
 
  
 
  
 
<span class="sprite article-type-text"></span>
 
  
 
  
 
  
 
<div data-picture class="article-more" data-alt="Article">
 
  
 
  
 
  
 
<div data-src="img/article-box-02-large.jpg"></div>
 
  
 
  
 
  
 
</div>
 
  
 
  
 
  
 
</a>
 
  
 
  
 
  
 
<div>
 
  
 
  
 
  
 
<a href=""><strongcontent category</strong></a>
 
  
 
  
 
  
 
<h4><a href="">content dscription</a></h4>
 
  
 
  
 
  
 
</div>
 
  
 
  
 
  
 
</li>
 
  
 
<% } %>
 
  
 
  
 
</ItemTemplate>
 
  
 
  
 
  
 
</asp:Repeater>
S D replied to Danasegarane Arunachalam on 15-Jan-13 08:23 AM
it does not work that way, it needs to have the #

Danasegarane Arunachalam replied to S D on 15-Jan-13 09:07 AM
What is the error message you are getting ?