来自MSDN代码~:
父窗体:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewClientClick.aspx.cs" Inherits="GridViewClientClick" %>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class GridViewClientClick : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick", "ReKey('" + e.Row.Cells[2].Text+e.Row.Cells[1].Text+"')");
//调用前台ReKey
//e.Row.Attributes["style"] = "Cursor:hand";
//键盘事件
//e.Row.Attributes.Add("OnKeyDown", "GridViewItemKeyDownEvent('" + e.Row.Cells[1].Text + "')");
}
}
}