使用Datagrid我在点击数据网格行上尝试Web表单,任何正文建议我如何执行此操作。
答案 0 :(得分:0)
为行添加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>