在2005中,如果在GridView中我们把某一列Visible=false,我们就得不到那一列的值。解决的办法:
1.适用于单值
例如我们对每一行ImageButton的HTML标记中加上如下一段:
CommandArgument='<%Eval("ID"%>'
取值的时候,如下可得到当前row的ID。
CType(sender, ImageButton).CommandArgument

2.多值、单值均可
可以把若干列放在模板列中,然后隐藏模板列。

3.传统方法,多值、单值均可
解决方法是在GridView的 RowDataBound 方法中动态把某列的Visible=false
 Protected Sub GridView1_RowDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        
'  If (e.Row.RowType = DataControlRowType.DataRow) Then

        e.Row.Cells(
8).Visible = False 'ID
        e.Row.Cells(9).Visible = False 'CnnID
        e.Row.Cells(10).Visible = False 'AppID

        
'  End If

    
End Sub

4.基本相似于3
解决方法是在GridView的 RowDataBound 方法中动态把cell的width设置为0,但这种方法测试,没有成功,不知道哪里有问题,还是列出来吧。
 Protected Sub GridView1_RowDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        
If (e.Row.RowType = DataControlRowType.DataRow) Then

            e.Row.Cells(
8).Width= New Unit(0)  'ID
            e.Row.Cells(9).Width = New Unit(0)  'CnnID
            e.Row.Cells(10).Width = New Unit(0)  'AppID

        
End If


    
End Sub