GridView 实现跳出新窗口 可以固定大小 非常好用

 

 

 

 

步骤是这样,现在代码里写个方法:
public string Fromat(object id)
  {
  return string.Format( "javascript:var win=window.open('testdraw.aspx?ID={0}',null,'width=300,height=200')",id);
  }
先把那超链接列转换成模板列
在属性上绑定 NavigateUrl='<%# Fromat(Eval("id")) %>'//掉用刚才写的方法。id的是你绑定的字段
就可以达到你的效果了

 

  <asp:GridView ID="GridViewManageUsers" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                CellPadding="4" ForeColor="#333333" GridLines="None"
                                OnPageIndexChanging="GridViewManageUsers_PageIndexChanging1" OnRowDeleting="GridViewManageUsers_RowDeleting">
                                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                                <Columns>
                                    <asp:TemplateField HeaderText="登陆名">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="HLLoginName" runat="server" Text='<%# Eval("LoginName") %>' NavigateUrl='<%# Fromat(Eval("UserId")) %>' />
                         
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="用户真实名称" ReadOnly="True" DataField="UserName" />
                                    <asp:BoundField DataField="Sex" HeaderText="性别" />
                                    <asp:BoundField DataField="Email" HeaderText="邮箱" ReadOnly="True" />
                                    <asp:BoundField DataField="QQ" HeaderText="QQ/MSN" />
                                    <asp:BoundField DataField="Hist" HeaderText="登陆次数" />
                                    <asp:TemplateField HeaderText="注册时间">
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("RegTime") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField ShowHeader="False">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                                                Text="删除"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle BackColor="White" />
                            </asp:GridView>

 

 

 

 

       /// <summary>
        /// 实现弹出固定大小新窗口
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string Fromat(object id)
        {
            return string.Format("javascript:var win=window.open('./UsersInfo.aspx?UserId={0}',null,'width=700,height=680,top=0, left=100')", id); //top=0, left=100' 是窗口位置
        }

阅读更多
个人分类: GridView相关
想对作者说点什么? 我来说一句

GridView72般绝技

2010年01月28日 275KB 下载

没有更多推荐了,返回首页

不良信息举报

GridView 实现跳出新窗口 可以固定大小 非常好用

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭