gridview 变色与双击

来源:互联网 发布:新网域名实名认证 编辑:程序博客网 时间:2024/04/28 02:55

protected void gvTrainClassInfo_RowDataBound(object sender, GridViewRowEventArgs e)

    {

        if (e.Row.RowType == DataControlRowType.DataRow)

        {

            //设置行颜色

            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='lightblue'");

            //添加自定义属性,当鼠标移走时还原该行的背景色

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

            string trainID = e.Row.Cells[1].Text.ToString().Trim();

         //Session["trainID"] = trainID;

          e.Row.Attributes.Add("ondblclick", "window.location.href='TrainPersonAdd.aspx?trainID=" + trainID + "'");

        }

}


原创粉丝点击