Click here to Skip to main content
15,886,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Comments
[no name] 15-Aug-12 9:41am    
Help with what issue? All you have provided is a vague description of your requirement. What is the problem? What errors are you getting? Where is the code that demonstrates your problem?
Oleksandr Kulchytskyi 15-Aug-12 9:47am    
The problem hides behind the passing of value which user choose in html select control
to HTML.Action method ...
HTML.Action("Search","Models",new {country =???}
Aditya Mangipudi 15-Aug-12 10:07am    
Do you have checkboxes for selection?
Oleksandr Kulchytskyi 15-Aug-12 10:22am    
No , my select control looks like this:
<p>
<fieldset>
Movie Type
<select id="prePurchaseType" name="Type">
<option value="0" selected="selected">Time to start</option>
<option value="1">Highest prize value</option>
</select>
<input type="submit" id="btnSearch" value="Search" />
</fieldset>
</p>
Aditya Mangipudi 15-Aug-12 10:30am    
Why are you not using html helpers. If you are doing it on MVC4, are you using Razor Engine?

1 solution

in my view controller, especially in Index method, i've implememnted few lines of code, see below:
C#
ViewBag.SearchType = (new List<SelectListItem>(){ new SelectListItem(){ Text="Time to start", Value="0", Selected=true},
                new SelectListItem(){ Text="Highest prize value", Value="1"}}).AsEnumerable();


and in View i've made such improvements:
HTML
@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.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900