判断语句出错!!为什么会提示当前上下文中不存在名称“Container”
<% if (CheckUser(userName, DataBinder.Eval(Container.DataItem, "UserName")))
{ %>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="编辑"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="删除"></asp:LinkButton>
<% } %>
如果为真显示编辑删除,如果为假不显示,上面判断语句怎么出错啊,还请各位大侠告知!
------解决方案--------------------
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="编辑" Visible="<%# GetVisible(Eval("UserName").ToString())></asp:LinkButton>
public bool GetVisible(string Name)
{
return CheckUser(userName, Name);
}
或在databound中设置visible