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

Hide edit button on formview

  I'm tryign to hide my edit linkbutton on a from view if the user doesn't have edit rights to something. On page load I give them a grid view. When they select something I hide the grid view and make the formview visible. The below code is what I thought I would need but the only time I get it to go down to the myControl1.Visible = False line is after the formview is on the screen and the user clicks the button. How do I keep the button from showing up in the first place?

 Protected Sub FormView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.Load
        Dim myControl1 As Control
        If CookieUtil.GetEncryptedCookieValue("edit") = "True" Then
            myControl1 = FormView1.FindControl("Edit")
            If (Not myControl1 Is Nothing) Then
                myControl1.Visible = False
            End If
        End If
    End Sub
0
t1clausen
Asked:
t1clausen
1 Solution
 
nehayaCommented:
On first time page load, you loaded the formview too.. as you noticed.
so I think the better way is to SPLIT the two forms, FormView is INITIALIZED after you choose from the GridView values..

However, if you like to continue your approach, I think we can find a soluition like this:
On Clicking of an item , before you make FormView1 visible, check the edit value as you did in FormView1_Load..!
and it's solved!

Regards,
Nehaya
0
 
t1clausenAuthor Commented:
Solved it! Dumb me. It needs to be in ItemCreated. Works great now.

    Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.ItemCreated
        Dim myControl1 As Control
        If CookieUtil.GetEncryptedCookieValue("edit") = "True" Then
            myControl1 = FormView1.FindControl("Edit")
            If (Not myControl1 Is Nothing) Then
                myControl1.Visible = False
            End If
        End If
    End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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