GridView精确控制弹出窗口大小位置

方法一:

1、前台增加ButtonField字段


2、后台代码:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {

        if (e.Row.RowType == DataControlRowType.DataRow)

        {

            if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)

           {

               String mystr = "window.open('default3.aspx?gwbm=" + e.Row.Cells[0].Text.ToString();

               mystr += "','','location=0,menubar=0,width=700,height=300');";

               ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", mystr);

            }

        }

      }

3、运行结果如下:

方法二:

1、前台增加模板列:

 

<asp:TemplateField HeaderText="岗位描述">
   <ItemTemplate>
       <a href="#" onclick="window.open('nbgwms.aspx?gwbm=<%# Eval("gwbm") %>','','location=0,menubar=0,width=700,height=200')"> 岗位描述</a>
   </ItemTemplate>

</asp:TemplateField>

2、后台不需要编写代码

3、运行结果如下:

 

 

posted @ 2015-09-23 11:23  xashxsy  阅读(208)  评论(0编辑  收藏  举报