c# - "if" Conditions in Formview Markup -
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 the second period and has more than 2 columns, if it has a third term. To find out what this is the word, I need to evaluate Terminumber property, and show the appropriate title. This is my mark up code:
(Eval ("TermNumber") == 2)%> & Lt;% {% & gt; & Lt; Th & gt; First Term Score & lt; / Th & gt; & Lt;%}% & gt; & Lt;% else if (Ev) ("TermNumber") == 3)%> & Lt;% {% & gt; & Lt; Th & gt; First Term Score & lt; / Th & gt; & Lt; Th & gt; Second term score & lt; / Th & gt; & Lt;%}% & gt; This is the result in run time error: Databasing method such as Eval (), XPath (), and bind () can be used only in the context of a database control. The reason for this is that Eval can only become part of a & lt;% #%> tag. Using
& lt;% #%> result is compiled in time compilation, and VS13 intellisense, its invalid word says.
My question is: How can I be successful in achieving my goal of showing the conditional columns? Can I use the condition in the markup of the databound control? Or in any other way to accomplish this, without making separate preparations for each term.
There is also a repeater control to show the form view, subject score, and also if the condition is to be used. / P>
So I am answering my question Thank you for the signal from Ruben's accepted answer: "server" visible = '& lt;% # (int) Eval ("TermNumber") & gt; 1%> '& Gt; First Term Score & lt; / Th & gt; & Lt; Th runat = "server" visible = '& lt;% # (int) Eval ("TermNumber") & gt; 2% & gt; '& Gt; Second term score & lt; / Th & gt; It also works without any problem in the repeater control, such as Runat = "Server" with no markup in the visible property, in the final output, it works perfectly fine Does. And if the code block is even more beautiful then the code.
Comments
Post a Comment