文章摘自:
http://www.cnblogs.com/sdikerdong/archive/2011/07/31/2122724.html
今天在做案子时候遇到用GridView控件时,想在里面有一个hyperlink,点击后弹出窗口再显示另外页面。可是在用DataNavigateUrlFormatString属性时,发现<hyperlinkFiled DataNavigateUrlFormatString="javascript:window.open('abc.aspx?...."这样写后,原来可以点击的hyperlink变成不可点击了。上网找有文章说是这是微软的Bug。在DataNavigateUrlFormatString中不能有“:”。网上给出的解决办法有两种:一种是将上述代码用itemTemplate来代替:
<asp:GridView ID="summaryGrid" runat="server"
AutoGenerateColumns="False"
...>
...
<Columns>
<%-- HACK: Ideally, we would just use an asp:HyperLinkField,
but there's a bug when specifying "javascript:" in the
DataNavigateUrlFormatString:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102300
As a workaround, use a TemplateField instead. --%>
<asp:TemplateField>
<HeaderTemplate>Date</HeaderTemplate>
<HeaderStyle CssClass="dateColumn" />
<ItemTemplate>
<a href='javascript:ShowItemDetail(<%# Eval("Id")%>)'>
<%# Eval("CreateTime", "{0:ddd MMM dd HH:mm}") %>
</a>
</ItemTemplate>
</asp:TemplateField>
...
</Columns>
</asp:GridView>
另外一种是用DataTextFormatString代替DataNavigateUrlFormatString。
http://www.vbforums.com/showthread.php?t=521952
<asp:HyperLinkField DataTextField="ID Control" DataTextFormatString="<a href=javascript:openWindow('{0}');>View</a>" />