服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服务器之家 - 编程语言 - ASP.NET教程 - 为GridView的行添加鼠标经过、点击事件的小例子

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

2019-11-21 13:32ASP.NET教程网 ASP.NET教程

这篇文章介绍了GridView的行添加鼠标经过、点击事件的小例子,有需要的朋友可以参考一下

代码如下:


   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')");
        }
    }        

延伸 · 阅读

精彩推荐