0

我的代码太长了,很抱歉:)

@model IEnumerable<Osos11.Models.Customers>
@Html.DevExpress().GridView(
settings =>
{
    settings.Name = "gvEditing";
    settings.KeyFieldName = "sno";
    settings.CallbackRouteValues = new { Controller = "Customer", Action = "EditingPartial" };
    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);

    settings.Columns.Add(column =>
    {
        column.Caption = "#";
        column.SetDataItemTemplateContent(c =>
        {
            ViewContext.Writer.Write(
                Html.ActionLink("Edit", "EditingEdit", new { sno = DataBinder.Eval(c.DataItem, "sno") }) + "&nbsp;" +
                Html.ActionLink("Delete", "EditingDelete", new { sno = DataBinder.Eval(c.DataItem, "sno") },
                    new { onclick = "return confirm('Do you really want to delete this record?')" })
            );
        });
        column.SetHeaderTemplateContent(c =>
        {
            ViewContext.Writer.Write(
                Html.ActionLink("New", "EditingEdit", new { sno = -1 }).ToHtmlString()
            );
        });
        column.Settings.AllowDragDrop = DefaultBoolean.False;
        column.Settings.AllowSort = DefaultBoolean.False;
        column.Width = 70;
    });
    settings.Columns.Add("Name");
    //settings.Columns.Add(column =>
    //{
    //    column.FieldName = "CategoryID";
    //    column.Caption = "Category";

    //    column.ColumnType = MVCxGridViewColumnType.ComboBox;
    //    var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
    //    comboBoxProperties.DataSource = NorthwindDataProvider.GetCategories();
    //    comboBoxProperties.TextField = "CategoryName";
    //    comboBoxProperties.ValueField = "CategoryID";
    //    comboBoxProperties.ValueType = typeof(int);
    //});
    settings.Columns.Add("CustomerNumber");
    //settings.Columns.Add("UnitPrice").PropertiesEdit.DisplayFormatString = "c";
    //settings.Columns.Add("UnitsInStock");
    //settings.Columns.Add("Discontinued", MVCxGridViewColumnType.CheckBox);

    settings.ClientLayout = (s, e) =>
    {
        if (e.LayoutMode == ClientLayoutMode.Loading)
        {
            if (Session["GridState"] != null)
                e.LayoutData = (string)Session["GridState"];
        }
        else
            Session["GridState"] = e.LayoutData;
    };
    settings.PreRender = (s, e) =>
    {
        if (ViewData["VisibleID"] == null) return;

        ASPxGridView grid = (ASPxGridView)s;
        grid.MakeRowVisible(ViewData["VisibleID"]);
    };
}).Bind(Model).GetHtml()

我收到了这个错误

Compiler Error Message: CS1660: Cannot convert lambda expression to type 'DevExpress.Web.Mvc.GridViewSettings' because it is not a delegate type
4

1 回答 1

1

看来这个问题是由 GridView 定义中的任何表达式都无效引起的。因此,View Engine 无法识别整个 GridView 的定义(lambda 表达式)。

于 2012-07-04T12:46:48.630 回答