有人可以帮助我如何将我的参数从组合框绑定到我的控制器中我的一个动作的参数。我正在使用 DevExpress 控制套件,这是我的代码:
 [HttpPost]
 public ActionResult Filter(string filterCriteria)
 {
     ViewData.Model = Repository.GetReports(filterCriteria);
     return RedirectToAction("Index");
 }
这是我的观点:
<div style="float:right;padding-bottom:20px;" >
@using (Html.BeginForm())
{
<table><tr><td>
Filter by Keyword:</td>
<td>
@Html.DevExpress().DropDownEdit(
    settings =>
    {
        settings.Name = "checkComboBox";
        settings.Width = 210;
        settings.Theme = Utils.CurrentTheme;
        settings.Properties.DropDownWindowStyle.BackColor = System.Drawing.Color.FromArgb(0xEDEDED);
        settings.Properties.ClientSideEvents.ValueChanged = "function(s, e) {e.customArgs[\"filterCriteria\"] = checkComboBox.Name.toString();}";
        settings.SetDropDownWindowTemplateContent(c =>
        {
            @Html.DevExpress().ListBox(
                listBoxSettings =>
                {
                    listBoxSettings.Name = "checkListBox";
                    listBoxSettings.SkinID = "CheckComboBoxListBox";
                    listBoxSettings.CallbackRouteValues = new { Controller = "Report", Action = "Filter" };
                    listBoxSettings.Theme = Utils.CurrentTheme;
                    listBoxSettings.ControlStyle.Border.BorderWidth = 2;
                    listBoxSettings.ControlStyle.BorderBottom.BorderWidth = 1;
                    listBoxSettings.ControlStyle.BorderBottom.BorderColor = System.Drawing.Color.FromArgb(0xDCDCDC);
                    listBoxSettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    listBoxSettings.Height = 100;
                    listBoxSettings.Properties.SelectionMode = ListEditSelectionMode.CheckColumn;
                    listBoxSettings.Properties.ClientSideEvents.SelectedIndexChanged = "OnListBoxSelectionChanged";
                }
            ).BindList(Repository.GetKeywords())
            .Render();
            ViewContext.Writer.Write("<table style=\"width:100%\"><tr><td align=\"right\">");
            @Html.DevExpress().Button(
                buttonSettings =>
                {
                    buttonSettings.Name = "buttonClose";
                    buttonSettings.Text = "Close";
                    buttonSettings.Style.Add("float", "right");
                    buttonSettings.Theme = Utils.CurrentTheme;
                    buttonSettings.ClientSideEvents.Click = "function(s, e){ checkComboBox.HideDropDown(); }";
                }
            )
            .Render();
            ViewContext.Writer.Write("</td></tr></table>");
        });
        settings.Properties.EnableAnimation = true;
        settings.Properties.ClientSideEvents.TextChanged = "SynchronizeListBoxValues";
        settings.Properties.ClientSideEvents.DropDown = "SynchronizeListBoxValues";
    }
).GetHtml()
</td><td>
@Html.DevExpress().Button(
    settings =>
    {
        settings.Name = "btnApply";
        settings.ControlStyle.CssClass = "button";
        settings.Text = "Apply";
        settings.UseSubmitBehavior = true;
        settings.Theme = Utils.CurrentTheme;
        settings.Width = 80;
        settings.RouteValues = new { Controller = "Report", Action = "Filter" };
    }
).GetHtml()
</td><td>
@Html.DevExpress().Button(
    settings =>
    {
        settings.Name = "btnClear";
        settings.ControlStyle.CssClass = "button";
        settings.Text = "Clear";
        settings.ClientSideEvents.Click = "function(s, e){ ASPxClientEdit.ClearEditorsInContainer(); }";
        settings.Theme = Utils.CurrentTheme;
        settings.Width = 80;
    }
).GetHtml()
</td></tr></table>
}
</div>
我基本上在底部有一个网格视图,我想用它上面的下拉列表进行过滤。我通过使用一个按钮来调用该操作来过滤我的收藏。在这个例子中,我只是试图传回控件的名称,即
settings.Properties.ClientSideEvents.ValueChanged = "function(s, e) {e.customArgs[\"filterCriteria\"] = checkComboBox.Name.toString();}";
只是想看看我是否能够传回任何值,但这失败了。有人可以详细说明一下这样做的方法吗?谢谢,