I am trying to have different options for different user roles. Here is my code:
Private Function GetApprovedBy() As String
If User.Identity.Name = "officer" Then
Return "Approved by Officer"
ElseIf User.Identity.Name = "manager" Then
Return "Approved by Manager"
Else
Return String.Empty
End If
End Function
Then inside my gridview templates I have:
<EditItemTemplate>
<asp:DropDownList ID="ApprovalEdit" runat="server">
<asp:ListItem>Rejected</asp:ListItem>
<asp:ListItem Text=<%= GetApprovedBy() %>></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
When I run the page I get
"Literal content ('<asp:ListItem Text=') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'."
Is there an alternative way of achieving this? Preferably without a DB.
Thanks in advance!!
Edit: I have also tried
<asp:ListItem><%= GetApprovedBy() %></asp:ListItem>
which failed with error 'Code blocks are not supported in this context'