Tips and tricks for .NET using ASP and VB code.

Make an Auto Generated Column in a GridView Invisible by Field Name.

        For Each GridViewTableCell As TableCell In e.Row.Cells
            If TypeOf GridViewTableCell Is DataControlFieldCell Then
                Dim GridViewDataCell As DataControlFieldCell = GridViewTableCell
                If TypeOf GridViewDataCell.ContainingField Is System.Web.UI.WebControls.AutoGeneratedField Then
                    Dim DataCellField As AutoGeneratedField = GridViewDataCell.ContainingField
                    If DataCellField.DataField = "FieldName" Then
                        GridViewTableCell.Visible = False
                    End If
                End If
            End If
        Next GridViewTableCell

No comments:

Post a Comment

Search This Blog