删除带图像的按钮

时间:2016-06-29 14:43:53

标签: asp.net-mvc razor devexpress devexpress-mvc

我在DevExpress for MVC中使用GridView实现了一个演示。

我想在GridViewPartial View中为Delete Button设置一个图像。

有人知道我该怎么设置它?

@{
var grid = Html.DevExpress().GridView(settings => {
...
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowEditButton = true;
...
            });
    if (ViewData["EditError"] != null){
    grid.SetEditErrorText((string)ViewData["EditError"]);
}
}

@grid.Bind(Model).GetHtml()

感谢Mates。

EDITED: 试试这个

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonSettings.Image;
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/content/images/icons/icon_delete.png";

它返回"需要参考,方法或属性非静态" DevExpress.Web.GridCommandButtonSettings.Image.get""

2 个答案:

答案 0 :(得分:0)

做到了,

在Razor View中(可能您使用的是GridViewPartial)通过以下方式定义按钮:

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonRenderMode.Image;
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/Content/Images/next.png";

答案 1 :(得分:0)

对于较新版本的DevExpress进行轻微更新。 ButtonType已deprecated支持渲染模式。

settings.SettingsCommandButton.RenderMode = GridCommandButtonRenderMode.Image; 
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/Content/Images/next.png";

<强>过时

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonRenderMode.Image;