将GridView 中的HyperLinkField 转换为TemplateField 模版字段
在前台代码修改为
<asp:TemplateField HeaderText="用户名">
<ItemTemplate>
<a class="AUserid" href="#"><%# Eval("userName") %></a>
</ItemTemplate>
</asp:TemplateField>
添加JS
$(function () {
$(".AUserid").click(function () {
var username = $(this).text();
window.showModalDialog("Detail.aspx?username=" + username , "newwindow", "dialogWidth=500px;dialogHeight=400px;toolbar =no;menubar=no;scrollbars=no;resizable=no;location=no;status=no");
alert(username);
});
});
这样就可以了
在模式窗口中经常会有用到GridView进行循环 加<base target="_self"/> 防止点击第2页...页面在新窗口打开