Question How to hide a Column in a gridview, Visual Web Developer

grafiksinc

New member
Joined
May 11, 2010
Messages
1
Programming Experience
Beginner
Hello All,

I have a Web Application I am developing that has a GridView.
I have searched the internet to no avail looking for an answer to this.

The gridview has 11 columns. I want to hide the 11th column while in normal mode and make visible while in edit mode.

Here is my Code:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowState = DataControlRowState.Edit Then
GridView1.Columns(11).Visible = True

ElseIf e.Row.RowState = DataControlRowState.Normal Then
GridView1.Columns(11).Visible = False

End If
End Sub


My result from the above code is The 11th column is not visible in Normal mode but when I click the Edit button an error StackOverflowExceptionwasunhandled comes up.

What am I missing
 
Back
Top