您的位置:首页 > 其它

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

2013-11-06 00:00 435 查看
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')");
        }
    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐