如何在gridview中为超链接添加属性

时间:2010-06-22 11:15:35

标签: asp.net gridview hyperlink

如何在数据绑定gridview中的超链接控件中添加rel =“example_group”等属性?

<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

没用。对所有人提前做出回应......

1 个答案:

答案 0 :(得分:1)

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

......失踪了。现在好了。