想用一个控件(或者是表格)显示一条数据,当双击控件(或表格)时可以用弹出的方式跳转到一个新的页面,在跳转的时候需要传递参数。

解决方案 »

  1.   

    神马问题啊,不会google啊随便给你贴一个。。不自己写了。///后台在数据绑定时注册一个JavaScript方法///////////
    protected void gvDraft_RowDataBound(object sender, GridViewRowEventArgs e)
            {
               if (e.Row.RowType == DataControlRowType.DataRow)
                    {
                       e.Row.Attributes.Add("onclick", "return openLink('" + url + "')");
                     }
            }
    ////////前台增加一个相应的JS方法//////////////
    function openLink(url) {
            window.open("MonthTargetAdjust.aspx?" + url, "1", "resizable=yes,toolbar=no,statusbar=no,menubar=no,location=no,scrollbars=yes,titlebar=no,width:900,height:700");
        }
      

  2.   

    注册属性。.Attributes["OnClick"]= "window.location.href=URL?参数Id=传递值"; 
      

  3.   

    RowDataBound里
    e.Row.Attributes.Add("onDblClick", "javascript:window.opener.location.href='子窗体B.aspx?id="+e.Row.Cells[1].Text.ToString() + "';window.close();");   
    e.Row.Attributes.Add("onDblClick", "javascript:window.opener.documentById('txt').value='"+e.Row.Cells[1].Text.ToString() + "';window.close();");   
      

  4.   

    aspx页面
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Demo1</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
            </asp:GridView>
        </div>
        </form>
    </body>
    </html>后台代码:
    public partial class Demo1 : System.Web.UI.Page
        {
            public class Employee
            {
                public string EmpID { set; get; }
                public string EmpName { set; get; }
            }        protected void Page_Load(object sender, EventArgs e)
            {
                this.GridView1.DataSource = new System.Collections.Generic.List<Employee>()
                { 
                      new Employee(){ EmpID="S001", EmpName="张三"},
                      new Employee(){ EmpID="S002", EmpName="李四"},
                      new Employee(){ EmpID="S003", EmpName="王五"},
                      new Employee(){ EmpID="S004", EmpName="赵六"},
                      new Employee(){ EmpID="S005", EmpName="小七"}
                };
                this.GridView1.DataBind();
            }        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("ondblclick", "window.open('DetailView.aspx?EmpID=" + DataBinder.Eval(e.Row.DataItem, "EmpID") + "');");
                }
            }
        }DetailView.aspx.cs获取EmpID
    /// <summary>
            /// 员工编号
            /// </summary>
            public string EmpID
            {
                get { return Request.QueryString["EmpID"] ?? string.Empty; }
            }