首页 > 编程 > .NET > 正文

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

2024-07-10 13:15:07
字体:
来源:转载
供稿:网友

复制代码 代码如下:


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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表