为GridView的行添加鼠标经过、点击事件的小例子
程序员文章站
2024-02-29 13:32:46
复制代码 代码如下: protected void gridview1_rowdatabound(object sender, gridviewro...
复制代码 代码如下:
protected void gridview1_rowdatabound(object sender, gridviewroweventargs e)
{
e.row.attributes.add("onmouseover", "c=this.style.backgroundcolor;this.style.backgroundcolor='#95b8ff'");
e.row.attributes.add("onmouseout", "this.style.backgroundcolor=c");
e.row.attributes["style"] = "cursor:hand";
int count = gridview1.rows.count;
string id = "";
for (int i = 0; i < count; i++)
{
id = gridview1.datakeys[i].value.tostring();
gridview1.rows[i].attributes.add("onclick", "newwin=window.open('default3.aspx?id=" + id + "','newwin','width=500,height=550')");
}
}
上一篇: Java小程序求圆的周长和面积实例 原创
下一篇: Java中的this指针使用方法分享