2014年7月13日 星期日

[RESOLVED] Gridview question


Hello all -


I have sort of a unique (I think) problem.  Here is my situation.  I have a DataTable in which I retrieve data from a stored procedure call, after which I bind to a gridView.  One of the columns I retrieve is text that contains a hyperlink , i.e. = .... .  This works fine and is syntactically correct.  After I bind the DataTable results to the gridView, I wish to have the data in the column be the actual link via the Hyperlink.  However, after binding the data to the Gridview, I get the actual
text, i.e. '" rather than the actual hyperlink.


Is there any way around this?  Hope my problem makes sense.



Hi,


Try to bind that hyperlink url, in to a "HyperLinkField" field.


Use the below links for help:


http://www.codeproject.com/Questions/143724/how-to-add-Hyperlink-in-gridview-in-ASP-NET


Hope this helps!


Thanks!



Actually your stored string is
encoded


You need to
decode
it in your gridview item template




<%# Server.HtmlDecode(Eval("Anchor").ToString()) %>


Regards.






You can set BoundField HtmlEncode property









Since it sounds like the column contains the full html for the link I suggest you use a Literal control. 


沒有留言:

張貼留言