列显示颜色数 [英] column shows the number of colors

查看:78
本文介绍了列显示颜色数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

每个人都会有一个问题.

在ASP.NET中,您希望按数字显示列颜色,同时增加列中的颜色数.

插图:

http://www.cuocsongso.com/forum/attachment.php?attachmentid=11461& d = 1302169075 [ ^ ]

请按照您显示的图像看起来像条形图一样,指导source

hello everyone!

There is a problem everyone would help.

In ASP.NET you want to display column color by number, while increasing the number of colors in the column increases.

illustrations:

http://www.cuocsongso.com/forum/attachment.php?attachmentid=11461&d=1302169075[^]

Please guide source

推荐答案

Hi.这可以通过使用Item模板中的Text或Label控件来实现.

1)有一个项目模板"列.里面有一个文本框控件/DIV元素包装在DIV元素内.
2)将文本框的背景设置为所需的颜色.
3)在gridview的RowDatabound事件中,将您的值转换为百分比.最大值为100%,并使用最大值作为分母缩放其他值.

4)使用您之前计算的百分比来计算长度的百分比.例如,您的文本框/div宽度为60px,值是35%,则新的宽度=(35/100)* 60.将此新宽度分配给文本框或div元素.对于零值,如果宽度未分配为零,则将背景色更改为白色.

希望对您有帮助
Hi as per the image you have shown looks like a bar chart. That can be achieved using a Text or Label controls inside a Item template.

1) Have a Item Template column. Inside that have a textbox control/ DIV element packed inside a DIV element.
2) Set the background of the textbox to the desired color.
3) At RowDatabound event of the gridview convert your value to percentage. The max value is 100% and scale other values using the max value as denominator.

4) Calculate the percentage of length using the percentage you calculated earlier. For example your textbox/ div width is 60px and your value is 35 percent then the new width= (35/100)*60. Assign this new width to the textbox or the div element. For zero value if the width is not assigned as zero then change the background color to white.

Hope this helps


这篇关于列显示颜色数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆