コントローラ:
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();
}