我试图在我的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
}
}
答案 0 :(得分:0)
试试这个 - 添加RowDataBound事件并执行以下操作:
e.Row.Visible = false;
答案 1 :(得分:0)
你需要访问行对象,然后你可以隐藏它,这有点棘手:
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removethis")
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
row.Visible = false;
}
}