后台行绑定事件里直接给行对象添加Attributes
比如
e.row.Attributes.add("onclick","alert("+ index +")");
这样点击行后就会执行脚本了,index是循环加出来地
比如
e.row.Attributes.add("onclick","alert("+ index +")");
这样点击行后就会执行脚本了,index是循环加出来地
解决方案 »
- XP下开发的asp.net2.0网站放到另一台机器上aspx文件无法浏览,这是怎么回事?急!!!
- asp.net 调试需要帐户和密码
- ASP.NET 角色管理问题
- 试图运行项目时出错,无法在WEB服务器上启动调试
- 超级郁闷的问题,高手解答下,100分
- (难解之谜)Java在asp.net 2.0内的问题
- ASP.NET连接数据库 急急急
- 怎么搞才能得到ProductID的值,谢谢高人指点!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
- Image:如何点击图片后看大图
- 求救在ASP.NET中到底如何使用INSERT INTO语句,希望专家指教(强烈要求置顶)
- gridView 自定义分页刷新问题
- vs2008预览出错
可以这样:
在GridView的RowDataBound设置一下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "test(" + e.Row.RowIndex + ")");
e.Row.Attributes.Add("style", "cursor: hand;");
}
}js获得:
<script type="text/javascript">
function test(mySelect)
{
alert(mySelect);
}
</script>
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "test(" + e.Row.RowIndex + ");return false;");
e.Row.Attributes.Add("style", "cursor: hand;");
}
} js获得:
<script type="text/javascript">
function test(mySelect)
{
alert(mySelect);
}
</script>