WEBSWAPP Silverlight ASP.NET 3.5 ASP.NET 2.0 ASP.NET 1.0
Cascading Lists
ITemplate
DDL in GridView
G/V MultiSelect
Nested GridViews
RegExp
DataGrid Reorder
Events fire twice
Hyperlink Field
TextBox
UpdateParameters
MultiView
TreeView
Demo

GridView HyperLinkField vs. the DataGrid HyperLinkColumn

There seems to be a subtle difference between the way the GridView’s HyperLinkColumn behaves when the hyperlink is a javascript (instead of a Url) and the way the DataGrid’s HyperLinkColumn used to behave.

In this demo I tried 4 scenarios:

  1. A HyperLinkField within a GridView: where I set the DataNavigateUrlFormatString="javascript:alert('you selected {0}');"
  2. A HyperLink within an ItemTemplate inside a GridView; where I set the NavigateUrl='<%# FormatLink(Eval("Text")) %>'
  3. A regular anchor tag (runat=”server”) within an ItemTemplate inside the GridView where I set the href='<%# FormatLink(Eval("Text")) %>'
  4. The HyperLinkColumn within a DataGrid where I set the DataNavigateUrlFormatString="javascript:alert('you selected {0}');"

The last 3 scenarios work but the first does not.

This GridView demonstrates the first 3 scenarios in corresponding 3 columns

This DataGrid represents the last scenario

HyperLinkColumn
Home
SilverLight
ASP.NET 3.5

Source code:

Demo source code