GridView的用法 使GidView变色

 protected void GVImage_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string strDescription = e.Row.Cells[4].Text.Trim().ToString();
            if (strDescription.Length > 22)
                e.Row.Cells[4].Text = strDescription.Substring(0,22)+"...";
            //使GridView 变色
            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");
            }
        }
//backgroundColor  这里的C一定要大写
posted @ 2007-09-16 22:18  wj-conquer  阅读(278)  评论(0编辑  收藏  举报