I have autogenerated columns here from visitid and so on. The first column however was a templatefield. now I wanted to hide VisitID. I tried this code but it didn't work. I am using vb as my codebehind
e.Row.Cells(1).Visible = False

I have tried several ways but also ended with this code and it worked finally I just added a condition. I'm sorry maybe I lacked information. I had a pagination in the gridview.. Here was my working code.
Protected Sub Gdvisitor_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Gdvisitor.RowCreated
If (e.Row.Cells.Count > 1) Then
e.Row.Cells(1).Visible = False
End If
End Sub
At first it was "....cells.count < 0" and that didn't work the index was still out of range but when I changed it to 1. It worked. I think the pagination has something to do with it. I'm not sure though... Thank you for all the help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With