我有一个gridview,它检查事件的一些值。rowDataBound
我想根据rowDataBound中检查的条件删除一些行。我尝试将所有控件放在面板中并隐藏该面板,即,
尝试 1:
protected void grdFeatured_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//some other codes here
//IMPLEMENT FILTER ACCORDING TO ABOVE 'VIS' OUTPUT
if (vis > 0)
{
Panel1.Visible = false;
}
}
}
问题 :
这会打乱分页,因为行是隐藏的,但会发生页数并显示剩余可见行的页码。
尝试 2:
protected void grdFeatured_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow gvr = e.Row;
if (e.Row.RowType == DataControlRowType.DataRow)
{
//some other codes here
//IMPLEMENT FILTER ACCORDING TO ABOVE 'VIS' OUTPUT
if (vis > 0)
{
gvr.Parent.Controls.RemoveAt(gvr.RowIndex);
}
}
}
问题 :
给出错误:
Specified argument was out of the range of valid values. Parameter name: index at gvr.Parent.Controls.RemoveAt(gvr.RowIndex);
不想编辑数据源,帮帮我。