给GridView行添加单击事件

将行的单击事件传递个服务器控件执行:

protected void ParentGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0 )
            {
                e.Row.Attributes.Add("id", "parent"+e.Row.RowIndex.ToString());
                e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(e.Row.Cells[9].FindControl("LinkButtonShowChild"), "")); 
            } 
        }

你可能感兴趣的:(.net,asp.net,asp)