无法隐藏gridview中的列 [英] Unable to hide column in gridview
本文介绍了无法隐藏gridview中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将数据集绑定到gridview,之后当我想要查看列时,它会收到以下错误:
I bind a dataset to gridview and after that when i want to unvisible the columns, it gets the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
我该怎么办?
这是我的代码:
what should i do?
this is my code:
GridView1.DataSource = myDataSet;
GridView1.DataKeyNames = new string[] { "IsRead" };
GridView1.DataBind();
GridView1.Columns[0].Visible = false;
GridView1.Columns[5].Visible = false;
GridView1.Columns[6].Visible = false;
GridView1.Columns[7].Visible = false;
GridView1.Columns[8].Visible = false;
推荐答案
如果你想在gridview中隐藏你的列,
指定< HeaderTemplate> property''visible =" False"''
或
在分配前删除特定列数据源到gridview。
If you want to invisible your column in gridview,
specify <HeaderTemplate> property ''visible = "False"''
or
Remove particular column before you assign datasource to gridview.
在这个网站上我找到了解决方案
http://forums.asp.net/t/1086562.aspx/1 [ ^ ]
in this site i found the solution
http://forums.asp.net/t/1086562.aspx/1[^]
这篇关于无法隐藏gridview中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文