简体   繁体   English

使用C#的Asp.Net,单击Datagrid行时打开Web表单

[英]Asp.Net using C#, Open Web form when click on the Datagrid row

使用Datagrid我正在尝试单击datagrid行上的Web窗体,任何机构都建议我如何执行此操作。

Add javascript click-eventhandler for a row 连续添加javascript click-eventhandler

Code behind 后面的代码

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow )
    {            
        User selUser = e.Row.DataItem as User;
        e.Row.Attributes.Add("onclick","openWindow('" + selUser.Id + "')");
    }
}

Javascript function Javascript功能

<script language="javascript">


        function openWindow( userId )
        {
            var url= "http://www.google.com";
            newwindow=window.open(url,'name','height=400,width=200');
        if (window.focus) {newwindow.focus()}
        }


    </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM