We help IT Professionals succeed at work.

asp.net c# gridview

riskyricky1972
on
1,975 Views
Last Modified: 2013-11-05
I have asp.net c# gridview and everything is working fine, and I just want to add hyperlink that will be able to carry a value like
primary key. (e.g. http://www123.com/default.aspx?hello=1) the 1 is come from the primary key valve
Comment
Watch Question

You can add a HyperLink column in your GridView like following:

  <asp:hyperlinkfield DataNavigateUrlFields="PrimaryFieldName"
                    DataNavigateUrlFormatString="http://www123.com/default.aspx?hello={0}"
                    DataTextField="DisplayFieldName"></asp:hyperlinkfield>

Here's Code & Example of this technique:
http://authors.aspalliance.com/aspxtreme/shared/viewsrc.aspx?path=/aspxtreme/sys/web/ui/webcontrols/demos/GridViewHyperLinkField.aspx.src

Author

Commented:
does not work. The hello={0} is harding code...I want it dynamically loaded from the primary key
hello={0} means "{0}" will get value of the Field specified in DataNavigateUrlFields (dynamic...)

If you look at the code & sample specified in example and scroll over the URL you'll notice the Dynamic ID value coming to each URL

Author

Commented:
it does not work as the way you said.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.