user168507
user168507

Reputation: 881

how to add attribute to hyperlink in a gridview

how can I add a attribute like rel="example_group" to a hyperlink control in a databound gridview?

<asp:HyperLink ID="HyperLink3" runat="server">HyperLink</asp:HyperLink>

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
    Dim myImage As HyperLink = CType(e.Row.FindControl("HyperLink3"), HyperLink)
    myImage.Attributes.Add("rel", "example_group")
End Sub

Didn't work. thx for all responce in advance...

Upvotes: 1

Views: 2550

Answers (1)

user168507
user168507

Reputation: 881

If e.Row.RowType = DataControlRowType.DataRow Then ... End If

... was missing. It's ok now.

Upvotes: 1

Related Questions