Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 8th, 2008, 11:30 AM
Authorized User
Join Date: Nov 2007
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hughesie78
Default Hyperlink url too long in data grid.

I have a datagrid, which is written to programatically, I want to populate one of the fields as URL, howevere the url's are quite long, so i just want to mask them all with the word "link", any ideas how i can do this?
here is my code:
<asp:HyperLinkField DataTextField="location" DataNavigateUrlFields=location HeaderText="Link" />

also, the link will work fine for URL's but then the value is a file directory it replaces the beginnig with the localhost address e.g

this link works fine when i open manually http://domain.company.net//download/word_doc.doc

but when opened as hyperlink through code above it comes out as http://localhost/Website/%20http://d...d/word_doc.doc

any ideas on both?
Thank You
Old May 9th, 2008, 08:26 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Add the "Text" attribute to the link field:

<asp:HyperLinkField DataTextField="location" DataNavigateUrlFields=location HeaderText="Link" Text="Link" />

Look at the URL that isn't working, it has a "%20" in it. This is the space character, so I suspect that you need to trim the value you are binding to the link field. The space is breaking the url. Also, if you are providing a url as an querystring value on another url you should url encode it:


Old May 12th, 2008, 11:54 AM
Authorized User
Join Date: Nov 2007
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hughesie78

thank you

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data too long for column 'ResumeInfo' at row 1 Snowby Pro PHP 0 April 2nd, 2008 02:32 AM
export data grid hyperlink column to excel phyzie VS.NET 2002/2003 0 April 16th, 2007 01:45 AM
How do you make a Data Grid Hyperlink Column pass KarmenC ASP.NET 1.x and 2.0 Application Design 5 January 13th, 2005 11:43 AM
How to use long text in data base? tiolele Classic ASP Databases 3 November 26th, 2003 09:15 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.