簡體   English   中英

使用C#的Asp.Net,單擊Datagrid行時打開Web表單

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

使用Datagrid我正在嘗試單擊datagrid行上的Web窗體,任何機構都建議我如何執行此操作。

連續添加javascript click-eventhandler

后面的代碼

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功能

<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