如何在运行时隐藏GridView列? [英] How to hide a column of GridView in runtime ?
问题描述
我将DataSet objetc绑定为我的GridView的数据源。但是我想省略显示的第一列。
如果我写了
GridView1.Columns( 0 )。可见=错误
然后我得到错误,说有一些索引错误。
怎么会这样?实现???
另外一个奇怪的事情是,当我尝试计数列时,它显示我数为0! :O
谢谢
Upniwesh
请参考:在ASP.NET中显示/隐藏GridView列 [ ^ ]
类似讨论:
如何隐藏ASP.Net Gridview列 [ ^ ]
试试这个:OnGridView1.RowDataBound
事件
GridView1.Columns(0).Visible = False
dgItems.Columns [0 ] .Visible = false;
或试试这个
protected void bla_RowCreated( object sender,GridViewRowEventArgs e)
{
e.Row.Cells [ 0 ]。可见= false ; // 隐藏第一列
}
http://stackoverflow.com/questions/2091457/how-to-hide-columns-in-an-asp-net-gridview-with-auto-generated-列 [ ^ ]
i认为它运作良好
<试试这个:
protected void GridView1_RowDataBound( object sender,GridViewRowEventArgs e)
{
e.Row.Cells [ 0 ]。可见= false ;
}
I am binding a DataSet objetc as a datasource to my GridView. However i want to omit first column from being displayed.
If i write
GridView1.Columns(0).Visible = False
then i get error saying there was some indexing error.
How can this be acheived ???
Also a weird thing is that when I try to count columns it displays me count as 0 !! :O
Thanks
Upniwesh
Please refer: Show / Hide GridView Columns in ASP.NET[^]
Similar discussion:
How to hide ASP.Net Gridview column[^]
Try this: OnGridView1.RowDataBound
event
GridView1.Columns(0).Visible = False
dgItems.Columns[0].Visible = false;
or try this
protected void bla_RowCreated(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; // hides the first column }
http://stackoverflow.com/questions/2091457/how-to-hide-columns-in-an-asp-net-gridview-with-auto-generated-columns[^]
i think it work well
try this:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; }
这篇关于如何在运行时隐藏GridView列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!