Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0 .NET4 MVC4
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 4:37am
Comments
Wes Aday at 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 at 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 at 15-Aug-12 10:07am
   
Do you have checkboxes for selection?
Oleksandr Kulchytskyi at 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 at 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 at 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 at 15-Aug-12 10:47am
   
Good to know.

1 solution

Rate this: bad
good
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" }))
{
	@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.
  Permalink  
v3

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

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 479
2 OriginalGriff 360
3 CHill60 280
4 CPallini 250
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076


Advertise | Privacy | Mobile
Web02 | 2.8.150327.1 | Last Updated 15 Aug 2012
Copyright © CodeProject, 1999-2015
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