Conditionally display fields in a gridview (ASP.Net)

The following code will display one of two fields based on the value of the first field. Place the following vb code within the RowDataBound event.

If e.Row.Cells(0).Text > "A" Then
e.Row.Cells(7).Visible = True
e.Row.Cells(8).Visible = False
Else
e.Row.Cells(7).Visible = False
e.Row.Cells(8).Visible = True
End If

e.Row.Cells(0).Visible = False

About Basil

Basil has over twenty years of programming experience from a wide variety of industries including warehouse distribution, insurance, state licensing for trucking industry, and discount retail. Programming language experience has predominantly been for IBM’s AS400 platform – CL, RPG, COBOL, Queries, Managed Queries, APF, SQL, Synon, Visual Basic and C++. He obtained his masters from the University of Mary-Hardin Baylor in 2007.
This entry was posted in ASP.Net. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *