我在后台添加了行点击变色事件。在前台的按钮中也可以得到这一行的id。但是点击了按钮时这一行的颜色就没有了,谁能给解决解决啊!谢谢了 
    前台
    <asp:HiddenField runat="server" ID="HiddenField1" />
    后台//数据绑定后激发事件
        protected void gren_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onclick ", "if(window.oldtr!=null){window.oldtr.runtimeStyle.cssText= '';}this.runtimeStyle.cssText= 'background-color:#ff7575';window.oldtr=this;document.getElementById('" + this.HiddenField1.ClientID + "').value='" + DataBinder.Eval(e.Row.DataItem, "sn_id").ToString() + "';");
            }
        }

解决方案 »

  1.   

    jquery
    $().ready(function(){
    $("#ShowProject tr:not(:first)").onclick(function () {
                $("#ShowProject tr:not(:first)").css("backgroundColor","White");
                $(this).css("backgroundColor", "#CCC");
            });
    }); 
      

  2.   

    $().ready(function(){
    $("#控件ID tr:not(:first)").onclick(function () {
                $("#控件ID tr:not(:first)").css("backgroundColor","White");
                $(this).css("backgroundColor", "#CCC");
            });
    }); 
      

  3.   

        protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            int i;
            for (i = -1; i < gv.Rows.Count; i++)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor,this.style.backgroundColor='#00A9FF'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                }
            }
    }
      

  4.   

    嗯!我在后台注册的事件,点击了按钮刷新了GridView。所以他的颜色也就没有了
      

  5.   


    放在<head ></head>里吗? 那在后台我怎么调用呢?