在Gridview asp.net中隐藏行
本文关键字:隐藏 net Gridview asp | 更新日期: 2023-09-27 17:55:02
我试图隐藏一行时,它的按钮点击在我的gridview。谁有解决这个问题的办法,我都是你的,
背后的代码:
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removethis")
{
Guid id = Guid.Parse(e.CommandArgument.ToString());
UsersBL.DeleteUserByUserId(id);
}
else
{
//hide the row
}
}
尝试添加RowDataBound事件,并这样做:
e.Row.Visible = false;
你需要访问row-object然后你可以隐藏它,这有点棘手:
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removethis")
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
row.Visible = false;
}
}