一步一步教你在GridView中实现可收缩的面板2011-05-27 博客园 朱祁林1、创建一个TestDB数据库:添加一张表Table_1,并向其中添加一些数据,表结构如下图。

2、新建一个asp.net网站。在Default.aspx上拖放一个GridView。在页面上加入下面切换层的js代码:
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById (whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}