ユーザーの役割ごとに異なるオプションを用意しようとしています。これが私のコードです:
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
次に、私の gridview テンプレート内に次のものがあります。
<EditItemTemplate>
<asp:DropDownList ID="ApprovalEdit" runat="server">
<asp:ListItem>Rejected</asp:ListItem>
<asp:ListItem Text=<%= GetApprovedBy() %>></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
ページを実行すると、
"Literal content ('<asp:ListItem Text=') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'."
これを達成する別の方法はありますか?できればDBなしで。
前もって感謝します!!
編集:私も試しました
<asp:ListItem><%= GetApprovedBy() %></asp:ListItem>
「このコンテキストではコードブロックはサポートされていません」というエラーで失敗しました