- //以下代码必须写在GridView中的ItemDataBound事件中
- if (e.Item.Cells[6].Text =="红色"
- {
- //当评分种类为不满意时背景色为红色
- e.Item.Cells[6].Attributes.Add("style", "background-color:#FF9999");
- }
- else if (e.Item.Cells[6].Text == "绿色"
- {
- //当评分种类为没有评时背景色为绿色
- //在此调用Color方法时必须引用命名空间using System.Drawing;
- e.Item.BackColor = Color.Green;
- }
- //让Button背景色半透明的方法
- btnSlect.BackColor = Color.Transparent; //使用Color必须引用命名空间using System.Drawing;