如何动态更改命令按钮的颜色? [英] How to change the color of a command button dynamically?

查看:218
本文介绍了如何动态更改命令按钮的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Gridview即'grvcart',其中有一个命令按钮,即'ShowEditButton'。

我想在运行时动态更改此按钮的背景颜色。我尝试使用以下代码抛出错误,如:'无法找到程序集'和另一个错误,指出'当前上下文中不存在颜色'。如何纠正这两个错误?



grvcart.Rows [e.NewEditIndex] .FindControl(ShowEditButton)。BackColor = Color.Red;

I have a Gridview namely 'grvcart' and within it I have a command button namely 'ShowEditButton'.
I want to change the back color of this button dynamically during runtime. I tried with the following code which throws errors like :' Cannot find assembly ' and another error stating that 'Color does not exist in current context'. How to rectify both these errors?

grvcart.Rows[e.NewEditIndex].FindControl("ShowEditButton").BackColor=Color.Red;

推荐答案

grvcart.Rows [e.NewEditIndex] .FindControl(ShowEditButton)。BackColor = System.Web.UI.HtmlControls.Color.Red;

或只是

System.Drawing.Color.Red;



-KR
grvcart.Rows[e.NewEditIndex].FindControl("ShowEditButton").BackColor =System.Web.UI.HtmlControls.Color.Red;
or just the
System.Drawing.Color.Red;

-KR


这篇关于如何动态更改命令按钮的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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