复制代码 代码如下:
<SPAN>就是想把DeleteButton 和EditButton 2个按钮隐藏</SPAN>
复制代码 代码如下:
<ItemTemplate>
<tr>
<td>
<asp:Button runat="server" CommandName="Delete" Text="删除" />
<asp:Button runat="server"
CommandName="Edit" Text="编辑" />
</td>
<td>
<div>
<asp:Label runat="server" Text='<%# Eval("UserName") %>' /></div>
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("Age") %>' />
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("IdentityCard") %>' />
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("LoginDate","{0:yyyy-MM-dd}") %>' />
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("LeaveDate","{0:yyyy-MM-dd}") %>' />
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("Population") %>' />
</td>
<td>
<asp:Label runat="server" Text='<%# Eval("HouseID") %>' />
</td>
</tr>
</ItemTemplate>
复制代码 代码如下:
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
Button DeleteButton = (Button)ListView1.FindControl("DeleteButton");
Button EditButton = (Button)ListView1.FindControl("EditButton");
string username = Session["username"].ToString();
if (username != "admin")
{
EditButton.Visible = false;
DeleteButton.Visible = false;
}
}
复制代码 代码如下:
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
Button DeleteButton = (Button)ListView1.FindControl("DeleteButton");
Button EditButton = (Button)ListView1.FindControl("EditButton");
string username = Session["username"].ToString();
if (username != "admin")
{
if (DeleteButton != null && EditButton != null)
{
EditButton.Visible = false;
DeleteButton.Visible = false;
}
}
}
复制代码 代码如下:
<asp:Button runat="server" Visible='<%#Session["username"]=="admin"?true:false %>'
新闻热点
疑难解答
图片精选