I am trying to insert an if statement into the table row of a .aspx file, and it seems that no matter what I do, it simply will not work. It's like trying to answer a question that has no right answer. Here is the code in question:
<%If Container.DataItem("ReportToolTipText") == 'Pending Approval' %>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" Font-Size="Medium" CommandName="Select" CommandArgument='<%# Eval("CertID") & "," & Eval("ReportID") & "," & Eval("PUCOID") %> ' OnClientClick="javascript:alert('This report is not editable');" OnCommand="CertLink_Clicked"><%# Container.DataItem("CertID")%></asp:LinkButton>
<asp:Label ID="lblCertSortName" runat="server" Font-Size="Medium" Text='<%# Container.DataItem("ReportDisplaySortName")%>'></asp:Label>
</td>
<% Else%>
<td>
<asp:LinkButton ID="LinkButton1B" runat="server" Font-Size="Medium" CommandName="Select" CommandArgument='<%# Eval("CertID") & "," & Eval("ReportID") & "," & Eval("PUCOID") %> ' OnCommand="CertLink_Clicked"><%# Container.DataItem("CertID")%></asp:LinkButton>
<asp:Label ID="lblCertSortNameB" runat="server" Font-Size="Medium" Text='<%# Container.DataItem("ReportDisplaySortName")%>'></asp:Label>
</td>
<% End If%>
I cannot get this code to run because it seems that every variation on the if statement at the top triggers an error statement. Here's the error message I get when I try to execute the code above:
BC30451: 'Container' is not declared. It may be inaccessible due to its protection level.
So I tried to encase the Container.DataItem variable in brackets and percent symbols like so, leaving the other lines of code unchanged:
<%If <%# Container.DataItem("ReportToolTipText") #> == 'Pending Approval' %>
And when I did, I got this error:
BC30081: 'If' must end with a matching 'End If'.
What is it talking about? I have an End If at the bottom.
So I tried encasing the Container.DataItem variable in single quotation marks along with the brackets and percent signs like so, leaving the other lines of code unchanged:
<%If '<%#Container.DataItem("ReportToolTipText")%>' == 'Pending Approval' %>
And when I do that, I get this error:
BC30201: Expression expected.
Again, there is an expression in the if statement.
So I tried encasing the entire expression in parentheses, like so, leaving the other lines of code unchanged:
<% If ('<%#Container.DataItem("ReportToolTipText")%>' == 'Pending Approval') %>
And I got the exact same error message that I did last time:
BC30201: Expression expected.
So I tried preceding the Container.DataItem variable with just a single number sign, like so, leaving the other lines of code unchanged:
<% If (#Container.DataItem("ReportToolTipText") == 'Pending Approval') %>
For the third time in a row, I get this error message:
BC30201: Expression expected.
What am I doing wrong? Any assistance anyone can provide me would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire