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一定要大写

你可能感兴趣的:(GridView)