gpt4 book ai didi

asp.net mvc 中的 DevExpress ComboBox SelectedIndexChanged

转载 作者:行者123 更新时间:2023-12-02 21:55:29 24 4
gpt4 key购买 nike

Controller :

public ActionResult ComboBox()
{

List<ComboBoxClass> Products = new List<ComboBoxClass>();
Products.Add(new ComboBoxClass { ProductName = "Masa" });
Products.Add(new ComboBoxClass { ProductName = "Sandalye" });
Products.Add(new ComboBoxClass { ProductName = "Bilgisayar" });
Products.Add(new ComboBoxClass { ProductName = "Laptop" });
Products.Add(new ComboBoxClass { ProductName = "Kulaklık" });
Products.Add(new ComboBoxClass { ProductName = "Bardak" });
Products.Add(new ComboBoxClass { ProductName = "Kalem" });
Products.Add(new ComboBoxClass { ProductName = "Seramik" });
Products.Add(new ComboBoxClass { ProductName = "Telefon" });

ViewData["Products"] = Products;

return View(Products);
}

查看:

@Html.DevExpress().ComboBox(
settings =>
{
settings.Name = "BenimComboBox";
settings.Width = 180;
settings.Properties.ValueField = "ProductName";
settings.SelectedIndex = -1;
settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
settings.Properties.DropDownStyle = DropDownStyle.DropDown;
settings.Properties.TextField = "ProductName";
settings.Properties.ValueField = "ProductName";
}
).BindList(ViewData["Products"]).GetHtml()

类别

public class ComboBoxClass
{
public string ProductName { get; set; }
}

我有产品。我列出了 ComboBox 上的所有产品。如何将我的 SelectedIndexChanged 值传递给 ActionResult ?

我想在“string SelectedItem ”下面看到选定的值

public ActionResult SelectedItemHere(string SelectedItem)
{
// Processes..
return View();
}

最佳答案

您需要将以下代码添加到您的组合框中,

settings.Properties.ClientSideEvents.SelectedIndexChanged = "SelectedId";

之后

布局中的 JavaScript 代码

function SelectedId() {
var data= {
SelectedItem: BenimComboBox.GetValue(),
};

$.ajax({
url: "/YOUR CONTROLLER/YOUR ACTİONRESULT",
type: "POST",
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(data),

最后,

Controller :

public ActionResult SelectedItemHere(string SelectedItem)
{
// Processes..
return View();
}

关于asp.net mvc 中的 DevExpress ComboBox SelectedIndexChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17898372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com