江湖救急: 隐藏和显示datalist 中的控件
前台:页面 datalist中,有两个控件,默认是隐藏的
<ItemTemplate>
<asp:LinkButton runat= "server " Text= "[置顶] " ID= "libnTop " CommandName= "Update " CommandArgument= "libnTop " Visible= "false "> </asp:LinkButton>
<asp:LinkButton runat= "server " Text= "[加精] " ID= "LibnPerfect " CommandName= "Update " CommandArgument= "LibnPerfect " Visible= "false "> </asp:LinkButton>
</ItemTemplate>
我在后台绑定的时候判断
private void TopicBind(DataTable dt)
{
dlstForumTopic.DataSource = dt;
dlstForumTopic.DataKeyField = "MessageID ";
dlstForumTopic.DataBind();
foreach (DataListItem item in this.dlstForumTopic.Items)
{
//判断是否为管理员,如果是,这两个控件就显示
if (Profile.UserInfo.UserID == nForumAdminID)
{
libnTop.Visible = true;
LibnPerfect.Visible = true;
}
}
}
单步跟踪,每次也能执行到,但是显示的时候却不能显示出来.太奇怪了
我跪求 各位给帮个小忙吧!
------解决方案--------------------(label)(dgPI.Items(i).Cells(j).Controls(1)).Visible