How to Insert anchor to every row in a gridview?

asoundmind

Member
Joined
Apr 14, 2007
Messages
6
Programming Experience
Beginner
Hi There, Nice to meet you all! Hopefully I can be active in this forum. I really hope you guys can help me out with my problem. I am planning to put an anchor on every row of my gridview which is bound to a datasource. The reason being is my Gridview is too long and user wants if they click on a link from other page, they can be redirected directly to the exact part of a specific row of that gridview. And I can't do paging as well 'coz they want all in one page so it can be exported and be seen easily in excel. Please help, any helps are very much appreciated. Thanks :D
 
Use the RowDataBound event. Example:
VB.NET:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
  If e.Row.RowType = DataControlRowType.DataRow Then
    e.Row.Cells(1).Text = String.Format("<a name=""{0}"" />{1}", e.Row.RowIndex + 1, e.Row.Cells(1).Text)
  End If
End Sub
 
Back
Top