如何在不使用visible属性的GridView中隐藏TemplateField列?

时间:2014-12-17 07:40:51

标签: javascript asp.net gridview

我们有system.web.ui.webcontrols.gridview in a aspx file which has several columns including个文本框,标签和组合框. We get the textboxes in a java script file using(document.getElementById())to use the values for our calculation and set the results to some other textboxes in the gridview. Now dues to lack of space we need to hide some columns that user do not need to see their values(we still need to read/write the values). To hide the desired columns in the gridview i set the VISIBLE to the false and it hides the columns, but the problem is that when I make a column invisible , document.getElementById()`什么都不返回然后我们无法将结果设置为不可见的文本框。

有没有其他方法可以隐藏列并继续在后台使用它们?

先谢谢你。 BR, Navid

2 个答案:

答案 0 :(得分:1)

您可以为这些列添加样式,它们将保留在后台

style="display:none";

或者你可以为这些列分配一个css类,在类中你可以编写display:none

答案 1 :(得分:1)

只需使用javascript将display设置为none,然后隐藏它的值,并且它的值是可访问的

 document.getElementById("myDIV").style.display = "none";