DataGrid FindControl的问题
DataGrid模版列有个表,表中放了个
<asp:LinkButton ID="del" CommandName="delete" Runat="server" Visible="false">删除</asp:LinkButton>
现在有权限的用户进入后要使Visible="true"
用FindControl怎么总提示:未将对象引用设置到对象的实例
我的代码:
if(Session["Admin"]!=null&&Convert.ToString(Session["Admin"])!=""){
if(DataGrid1.FindControl("del")!= null)
{
((LinkButton)DataGrid1.FindControl("del")).Visible=true;
}
}