隐藏在asp.net中的GridView行 [英] Hide a gridView row in asp.net
问题描述
我创建一个 GridView控件
,允许通过添加必需的INSERT INTO控件添加新行 FooterTemplate
,但是当 ObjectDataSource控件
有没有记录,我想补充一个虚拟行作为 FooterTemplate
当有数据仅显示
I am creating a gridView
that allows adding new rows by adding the controls necessary for the insert into the FooterTemplate
, but when the ObjectDataSource
has no records, I add a dummy row as the FooterTemplate
is only displayed when there is data.
如何隐藏这个虚拟的行?我已经尝试设置 e.row.visible = FALSE
在的RowDataBound
,但该行仍是可见的。
How can I hide this dummy row? I have tried setting e.row.visible = false
on RowDataBound
but the row is still visible.
推荐答案
您可以处理GridView的数据绑定事件和隐藏虚拟一行。 (不要忘了事件属性在ASPX code分配):
You could handle the gridview's databound event and hide the dummy row. (Don't forget to assign the event property in the aspx code):
protected void GridView1_DataBound(object sender, EventArgs e)
{
if (GridView1.Rows.Count == 1)
GridView1.Rows[0].Visible = false;
}
这篇关于隐藏在asp.net中的GridView行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!