首页 新闻 会员 周边

GridView 双击行事件

1
悬赏园豆:20 [已解决问题] 解决于 2012-02-27 22:26

GridView 双击行事件怎么实现。

需求,绑定Gridview数据,双击时候获得这行的数据。怎么实现?

双击行事件?有没有完整的解决方案?或者例子?谢谢

Astan的主页 Astan | 初学一级 | 园豆:13
提问于:2012-02-26 20:52
< >
分享
最佳答案
1
 protected void gridList_RowDataBound(object sender, GridViewRowEventArgs e)
{

//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
//行事件,千万不要写循环,本身ROWDATABOUND就是循环的
e.Row.Attributes.Add("dbclick", "可直接写JS代码也可写JS函数,然后前台设置JS函数");
//列事件,可以循环实现多列
            e.Row.Cells[1].Attributes.Add("onclick", "showedit(this)");
e.Row.Cells[3].Attributes.Add("onclick", "showedit(this)");
}

}
收获园豆:10
happydaily | 菜鸟二级 |园豆:301 | 2012-02-27 17:52
其他回答(1)
2

给gridview添加一个双击事件,参考这个问题:关于Gridview单双击问题

收获园豆:10
artwl | 园豆:16736 (专家六级) | 2012-02-27 09:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册