在ASP.NET MVC中选择更改时更改表结果 [英] change table result on select changed in ASP.NET MVC
本文介绍了在ASP.NET MVC中选择更改时更改表结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.
我需要根据选定的值更改ASP.NET MVC应用程序中的表内容
在HTML中选择控件.
谁可以帮助我解决此类问题?
通常html select包含不同的国家/地区,因此,例如,当用户选择
美国,所有表数据都必须更改为美国.
Hi guys.
I need to change table content in ASP.NET MVC application according to selected value
in HTML select control.
Who can help me with such issue ?
in general html select contains differ countries, so for an example, when user choose
USA, all table data must changed to USA.
推荐答案
在我的视图控制器中,尤其是在Index方法中,我实现了几行代码,请参见下文:
in my view controller, especially in Index method, i''ve implememnted few lines of code, see below:
ViewBag.SearchType = (new List<SelectListItem>(){ new SelectListItem(){ Text="Time to start", Value="0", Selected=true},
new SelectListItem(){ Text="Highest prize value", Value="1"}}).AsEnumerable();
并在View中进行了这样的改进:
and in View i''ve made such improvements:
@using (Html.BeginForm("Index", "PrePurchase", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.DropDownList("SearchType");
<input type="submit" value="View" />
}
也许这不是礼貌的方法,但是它对我有帮助,并且我的视图开始与控制器一起正常工作.
Maybe this is not polite way , but it helps me , and my view started work properly in conjunction with controller.
这篇关于在ASP.NET MVC中选择更改时更改表结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文