日期:2014-05-18  浏览次数:20516 次

JS如何隐藏DataGrid中的某一列?????????
在前台如何用JS隐藏DataGrid中的某一列不显示??????
帮帮忙
谢谢大家

------解决方案--------------------
private void dgPackageSubType_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.DataItem is DataRowView)
{
if(要隐藏)
e.Item.Style.Add( "display ", "none ");
}
}

------解决方案--------------------
其实,html中是没有DataGrid的。
------解决方案--------------------
后台对行做标记,前台再用js隐藏
------解决方案--------------------
table的话可以这样

<table id= "t ">
<tr style= "display:none; "> <td> 第一行 </td> </tr>
<tr> <td> 第二行 </td> </tr>
<tr> <td> 第三行 </td> </tr>
<tr> <td> 第四行 </td> </tr>
<tr> <td> 第五行 </td> </tr>
</table>
<button onclick= "document.getElementById( 't ').rows[2].style.display= 'none ' "> 隐藏第三行 </button>
------解决方案--------------------
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
※以下是引用楼主 Net_Study() 在2007-06-11 12:24:55 的发言:
──────────────────────────────────────────
楼上的,HTML是没有DataGrid,
但是你能获取DataGrid的ID吗?肯定可以的呀
我就是不知道怎么获取DataGrid里面的元素撒
帮帮我撒
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Datagrid就是TABLE吧,我上面不是给你两种方法了吗
------解决方案--------------------


var grid = document.getElementById( "gridID ");

for(var i = 0;i <grid.rows.length;i++){
for(var j= 0;j <grid.rows[i].cells.length;j++){
if(j == 你要的列){
grid.rows[i].cells[j].style.display = 'none ';
}
}
}
------解决方案--------------------
夏天以南 right