GridView 弹出模式窗口

来源:互联网 发布:萧山网络问政益农 编辑:程序博客网 时间:2024/06/06 23:21

将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页...页面在新窗口打开