---
title: "If statement inside Repeater control"  
description: "If statement inside Repeater control"  
author: "Anonymous User"  
published: 2015-06-02  
updated: 2015-06-02  
canonical: https://www.mindstick.com/forum/23279/if-statement-inside-repeater-control  
category: "asp.net"  
tags: ["c#"]  
reading_time: 1 minute  

---

# If statement inside Repeater control

Although there are several [questions](https://www.mindstick.com/blog/124895/hp-hpe0-s54-cheat-sheet-exam-questions-bank-for-guaranteed-success) on this topic, I haven't found any satisfactory answers.

I have a [Repeater](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) that needs to display [complex](https://yourviews.mindstick.com/audio/1142/understanding-the-complex-factors-influencing-mental-health) [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand). An [IF statement](https://www.mindstick.com/forum/12682/jquery-toggle-if-statement) is [required](https://www.mindstick.com/forum/160269/what-is-required-data-annotation-how-does-it-affect-model-validation) within the template. I can't move this to the code-behind as I need to have [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) controls and [user controls](https://www.mindstick.com/forum/343/logon-and-logoff-user-controls-how-to-set-isauthenticated-is-true) registered within the repeater. Here is what I need:

```
<asp:Repeater ID="rCom" runat="server" ClientIDMode="Static">    <ItemTemplate>       <%# If CBool(Eval("IsFix")) Then%>           <%-- HTML content including server and user controls --%>       <%Else%>           <%-- HTML content including server and user controls --%>       <%End If%>    </ItemTemplate></asp:Repeater>
```

The above throws a [compiler](https://www.mindstick.com/articles/27/just-in-time-compiler) error. Any idea on how to achieve this? I need to evaluate the IsFix field in the If statement.

## Replies

### Reply by Anonymous User

Remove # from the code nuggets which is having if statement:-

```
<asp:Repeater ID="rCom"runat="server" ClientIDMode="Static">    <ItemTemplate>       <%CBool(Eval("IsFix")) Then%>           <%--HTML content including server and user controls --%>       <%Else%>           <%--HTML content including server and user controls --%>       <%EndIf%>   
</ItemTemplate></asp:Repeater>
```

**Edit:**

Try with conditional operator (I am not sure about the syntax in VB.NET, please check):-

<%# If(CBool(Eval("IsFix")), "Do Something", "Else do something" %>


---

Original Source: https://www.mindstick.com/forum/23279/if-statement-inside-repeater-control

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
