I want to show a student report card using a form view. The report card will have additional columns, if it is a report card from 2nd term and 2 more columns, if its from 3rd term. To find out which term it is, I need to evaluate the TermNumber Property, and show the appropriate heading. This is my mark up code:
<% if ((int)Eval("TermNumber") == 2) %>
<% { %>
<th> 1st Term Score</th>
<% } %>
<% else if ((int)Eval("TermNumber") == 3) %>
<% { %>
<th> 1st Term Score</th>
<th> 2nd Term Score</th>
<% } %>
This results in run time Error : Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
This is because Eval can only be part of a <%# %> tag.
Using <%# %> results in compile time error, and the VS13 intellisense, says its invalid term.
My Question is: How can I succeed in achieving my target of conditionally showing the columns. Can I use the if Condition in the markup of the Databound controls? Or is there any other way to achieve this, without creating separate formviews for each term.
The Form View, also has a repeater control to show the subject scores, and also needs to utilise the if Condition.