动态显示被隐藏的gridview列,列是在RowCreated被隐藏的~~有无办法~在线等待结帖~~
gridview列隐藏代码
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[1].Visible = false; //如果想使第1列不可见,则将它的可见性设为false
}
入题,我想通过一个按钮动态的控制gridview某一列是否显示。
protected void Button3_Click(object sender,EventArgs e)
{
控制gridview某一列是否显示代码
}
能否做到,代码怎么写;
不要这种隐藏,显示方式
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.Columns[1].Visible = false;
}
------解决方案-------------------- <script type= "text/javascript ">
function showcolumn(index)
{
for(var i=0;i <GridView1.rows.length;i++)
{
GridView1.rows[i].cells[index].style.display = "none ";// "inline "
}
}
</script>
<input type= "button " value= "SHOW " onclick= "showcolumn(1) " />
------解决方案--------------------可不可以利用宽度来控制?