7. April 2006 06:17
/
0
/
Comments (20)
When you always think something is going to go very smooth you know there will be something to make it rough. Of course I'm talking about code. As the title might have given it away, I'm talking about the GridView. To be more specific: a GridView with a HyperLinkField and JavaScript.
In 2005, a HyperlinkField cannot have javascript. For some reason if you do something like this:
<asp:HyperLinkField HeaderText="PLAN IMG" DataTextField="PLAN_IMG" Text="{0}" SortExpression="PLAN_IMG" DataNavigateUrlFields="PLAN_IMG" DataNavigateUrlFormatString="javascript:MM_openBrWindow('../images/elevations/{0}','img','');"/>
The grid will be rendered without a hyperlink. How to solve this problem, you may ask. After reading this blog I came up with a solution. Use a BoundField with a dataformatstring of an anchor.
<asp:BoundField DataFormatString="<a href=javascript:MM_openBrWindow('../images/elevations/{0}','img','');>{0}</a>" DataField="PLAN_IMG" HeaderText="PLAN_IMG" SortExpression="PLAN_IMG" />
Please note that I don't have any spaces in the href=. Hope this helps you guys.
Happy Programming!
e05db9bf-dd07-4bd5-8e69-c6f65229fd66|54|2.6|27604f05-86ad-47ef-9e05-950bb762570c