Click here to Skip to main content
12,882,812 members (40,363 online)
Rate this:
Please Sign up or sign in to vote.
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 15-Aug-12 3:37am
Wes Aday 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:
Movie Type
<select id="prePurchaseType" name="Type">
<option value="0" selected="selected">Time to start</option>
<option value="1">Highest prize value</option>
<input type="submit" id="btnSearch" value="Search" />
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?
Oleksandr Kulchytskyi 15-Aug-12 10:46am
Yep, I'm in favor of Razor.
So for now i've resolved this.
Thanks for your help.
Aditya Mangipudi 15-Aug-12 10:47am
Good to know.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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();

and in View i've made such improvements:
@using (Html.BeginForm("Index", "PrePurchase", FormMethod.Post, new { enctype = "multipart/form-data" }))
	<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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170422.1 | Last Updated 15 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100