• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 122
  • Last Modified:

Find Templete field Gridview

HI

I'm trying to hide or display a template gridview button depending on whether the results of a session matches the logged in user.

I'm not doing something right as it can't find  ' CancelApt ' when I run the code.

Protected Sub GVCurrent_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVCurrentRowDataBound



[code]            Dim CancelApt As Button

            CancelApt = DirectCast(e.Row.FindControl("btnCancelApt"), Button)

                     
                If Session("UserID")  = User.Identity.Name Then

                    CancelApt.Visible = True
 Else

                    CancelApt.Visible = False
                End If

Open in new window

0
Ed
Asked:
Ed
1 Solution
 
dejaanbuCommented:
you have to check whether this is a datarow first
Protected Sub GVCurrent_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVCurrentRowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
//here ur codes
End if
End sub

Open in new window

0
 
EdAuthor Commented:
Doh!

Works perfectly..  Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now