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 の定義の式が無効であることが原因であると思われます。その結果、GridView の定義 (ラムダ式) 全体がビュー エンジンによって認識されません。

于 2012-07-04T12:46:48.630 に答える