导航

隐藏GridView列

Posted on 2006-05-09 12:42  ansonchou  阅读(463)  评论(0)    收藏  举报

不知是不是微软的一个BUG ,DataGrid 可以直接设某列的Visible=false.
但如果在GridView中把Visible=false就找不到这一列.
解决方法是在GridView的 RowDataBound 方法中动态把某列的Visible=false

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 
{

        
if (e.Row.RowType == DataControlRowType.DataRow)
       
{
           e.Row.Cells[
8].Visible = false//status
           e.Row.Cells[9].Visible = false//rqId
           e.Row.Cells[10].Visible = false;//rqType
       }

}