Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net AspxGridView:如何使用图像作为编辑按钮?_Asp.net_Devexpress_Aspxgridview - Fatal编程技术网

Asp.net AspxGridView:如何使用图像作为编辑按钮?

Asp.net AspxGridView:如何使用图像作为编辑按钮?,asp.net,devexpress,aspxgridview,Asp.net,Devexpress,Aspxgridview,我有一个Aspxgridview控件,并且启用了编辑。因此,有一个列叫做“编辑”。当我按下它时,它会弹出行编辑窗口——到目前为止,你们都知道这一点 当我按下编辑按钮时,有2列需要编辑。当这些列还没有编辑时,我想显示一个红色的图像而不是编辑按钮(我的数据库中有一个编辑过的布尔值-默认值为0),编辑后,我想用一个绿色的图像来更改这个图像。我有一个布尔列,有两个图像和一个带有editbutton的命令列。有可能做到这一点吗 提前感谢。是的,可以实施。首先,应该将CommandColumn.Button

我有一个Aspxgridview控件,并且启用了编辑。因此,有一个列叫做“编辑”。当我按下它时,它会弹出行编辑窗口——到目前为止,你们都知道这一点

当我按下编辑按钮时,有2列需要编辑。当这些列还没有编辑时,我想显示一个红色的图像而不是编辑按钮(我的数据库中有一个编辑过的布尔值-默认值为0),编辑后,我想用一个绿色的图像来更改这个图像。我有一个布尔列,有两个图像和一个带有editbutton的命令列。有可能做到这一点吗


提前感谢。

是的,可以实施。首先,应该将CommandColumn.ButtonType设置为图像值。要自定义按钮的图像,请使用ASPxGridView的事件。下面是一个示例代码:

protected void ASPxGridView1_CommandButtonInitialize(object sender, ASPxGridViewCommandButtonEventArgs e) {
    if(e.ButtonType == ColumnCommandButtonType.Edit) { 
        if(e.VisibleIndex % 2 == 0)
            e.Image.Url = "Images/Copy.bmp";
        else
            e.Image.Url = "Images/Design.bmp";
    }
}

至少我现在能看到红色了。但它不接受“e.ButtonType”。缺少什么?您使用的是哪个版本的ASPxGridView?另外,请将代码粘贴到这里…DX.9.1。现在还没有代码,我只是给出了你所说的事件,它没有显示e的ButtonType。事情就是这样发生的:如果(e.Button.ButtonType==ColumnCommandButtonType.Edit){e.Button.Image.Url=“~/images/positive.png”}但是现在网格属性不起作用,我的意思是当我单击时,什么都没有,当我点击页码时,什么都没有。两条评论都是以相同的类型发布的,请看上面。