0

is it possible to put a repeater inside a if statement like

<% if(1 == 2) { %>                                                           
 Return: <asp:Repeater runat="server" DataSource='<%# Eval("returnDetails") %>'>
     <ItemTemplate>
       <%# Eval("from") %> 
       <%# Eval("to") %> 
     </ItemTemplate>
 </asp:Repeater>
<% } %>

But this runs even if isReturnDetailsExist is false, and so throws exception that returnDetails doesn't exist, anyone?

Luckyy
  • 1,021
  • 4
  • 15
  • 29
  • It is better to filter the data source in code behind. – KV Prajapati Jun 03 '14 at 03:41
  • 1
    can you put the code `isReturnDetailsExist` where you are receiving the value as well ? – Ali Jun 03 '14 at 03:41
  • Yes, it works that time,,as its true in that case - Ali AVD- But this case wil again come even in that case when binding in repeater – Luckyy Jun 03 '14 at 03:43
  • 1
    I guess my question is from where do you get the value of `isReturnDetailsExist`, is this a property from your code behind ? the value of `isReturnDetailsExist` might be refreshed on page load, can you check the value on break point ? – Ali Jun 03 '14 at 03:46
  • Yes....even I removed isReturnDetailsExist and I put if (1 == 2), in that case too it runs – Luckyy Jun 03 '14 at 03:48
  • I edited the question to be more precise (1== 2) – Luckyy Jun 03 '14 at 03:53
  • I just run your code and it works fine at my end, could you take `DataSource='<%# Eval("returnDetails") %>` out of your code and try again ? – Ali Jun 03 '14 at 03:57
  • If I remove this it will work for sure, but this is what I needed, I can't remove that...this is what I am working on – Luckyy Jun 03 '14 at 04:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/54959/discussion-between-ali-shahrokhi-and-luckyy). – Ali Jun 03 '14 at 05:00

0 Answers0