- //以下代码必须写在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;
GridView中的行的背景色根据条件来显示不同的颜色和Button按钮半透明的方法
最新推荐文章于 2025-03-12 14:31:36 发布
本文介绍如何在ASP.NET中通过GridView的ItemDataBound事件改变单元格背景颜色,包括根据不同条件设置不同颜色的方法,并展示了如何使按钮背景变为半透明。
5164

被折叠的 条评论
为什么被折叠?



