Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GridView - dynamically disable HyperLinkField

Status
Not open for further replies.

WMXTeam

Programmer
Oct 5, 2005
41
US
I have a grid with the company name in the first column as a HyperLinkField. When the link is clicked, the user is taken to another page.

I need to disabled the link under if the user does not rights to update this companies information. I have the logic to check for the user rights. However, I am stumped as to how to disable the Hyperlink.

Any feedback and/or ideas are greatly appreciated.
 
one way is to disable the link or grid view row render, using the RowDataBound method, then search for the link and disable.
 
I spend several hours trying to do this. However, the HyperLinkField column object does not have a enable / disable property. Any other suggestions?
 
You have to find the hyperlink control in the hyperlink column. Here is an example, you have to change the indexes to match your column indexes:
Code:
      If e.Row.RowType = DataControlRowType.DataRow Then
            Dim x As HyperLink
            [blue]x = e.Row.Cells(0).Controls(0)[/blue]
            x.NavigateUrl = "#"
            If e.Row.RowIndex = 1 Then
                x.Visible = False
            End If
        End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top