前台javascript取gridview行号 后台行绑定事件里直接给行对象添加Attributes比如e.row.Attributes.add("onclick","alert("+ index +")");这样点击行后就会执行脚本了,index是循环加出来地 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接取好象有点困难!!可以这样:在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> 如果点击时不想刷新页面就改成如下所示: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { 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> 关于防止Sql注入 问个问题 200分。 如何返回Post消息 javascript的问题(2) Pxzit.WebControls.DataGridNavigator.dll控件的问题,大家帮帮忙吧 代码转换,在线等 |M| 300分 麻烦大家贴出您现在用的SQL分页存储程按主键排序和按非字键排序 再说说性能怎么样 发者有分 谢谢 gridview分页的问题 请问如何在asp.net中间隔一定时间 重复call一个函数??? Rose2000 支持 .Net吗? 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>