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

how to read text of hyperlink of a gridview

Hi there,

is it possible to read the text of hyperlink field of a gridview without converting it to the template?
 i am looping thorugh to the gridview to get the values of the template fields like this

foreach(GridViewRow row in GrdKPIs.Rows)
                     if (row.RowType != DataControlRowType.DataRow)

                     TextBox txtAct = (TextBox)row.FindControl("txtActualV");
                     Label lblID = (Label)row.FindControl("lblObjValID");
Thanks for your help.

Ali Shah
Ali Shah
  • 2
1 Solution
Kyle AbrahamsSenior .Net DeveloperCommented:
HyperLink hl =  (Hyperlink) row.FindControl("NameOfHyperLink");
Ali ShahSQL DeveloperAuthor Commented:
Thanks for the reply. but the hyperlink is defined as follows in the gridview and i don't think that the hyperlinkd contains id or name property

<asp:HyperLinkField DataTextField="InternalComments" DataNavigateUrlFields="ObjValID" DataNavigateUrlFormatString="InternalComments.aspx?ObjvalID={0}"
                         Target="_blank" HeaderText="Internal Comments" />
HyperLinkField are rendered as <a> tags without any ID.
So you will have to use a templated field. Any reason why you don't want to use TempaltedField?

Here's an example of how to use Hyperlink inside of GV Template.
Ali ShahSQL DeveloperAuthor Commented:
Thanks it worked
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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