网络编程 
首页 > 网络编程 > 浏览文章

为GridView的行添加鼠标经过、点击事件的小例子

(编辑:jimmy 日期: 2025/12/29 浏览:3 次 )
复制代码 代码如下:
   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')");
        }
    }       
上一篇:.net开发中批量删除记录时实现全选功能的具体方法
下一篇:asp.net中生成缩略图并添加版权实例代码
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap