Click to See Complete Forum and Search --> : Evaluating which text to display as link caption on a GridView


Nuno Tavares
November 16th, 2005, 03:40 PM
Hello all (first post here, old user from the VC++ forum :)

I'm trying to build a list from a database using a GridView with HyperLinkField bounding. The field in question is an URL, which is not always specified (IOW, it may be null). So, I want to display (let's say...) YES (with a link to the URL) if the URL exists, or NO if it doesn't. It there anyway to do this by using the tools? Must it be done by code?

I'm using Visual Studio 2005. And BTW, if you try to link with an e-mail, it won't construct the link - is this a bug?

-
Nuno

Nuno Tavares
November 16th, 2005, 07:53 PM
As soon as I've posted the message, I found an interesting article[1]. Now I want to go bold, and output a link if there is the website, or nothing ("") if there isn't. This is my code:


protected string ShowWebsiteIfAny(string ws)
{
if (ws.Length != 0)
{
return "<a href=\"http://\""+ws+"\">YES</a>";
}
return "";
}


Now, when running this, IE (6) reports "errors on the page". How can I output a link in the ASP.NET way?


[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/GridViewEx07.asp?frame=true&hidetoc=true