Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After validation dropdown list do not select previous value.


Java
%: Html.DropDownList("Country",(SelectList)ViewData["Country"],"") %



However in Quick View there is correct selected value. :(
Posted
Updated 6-Nov-11 21:36pm
v4
Comments
m19anand 7-Nov-11 3:24am    
Hi ,...


At present im facing the same problem as you,.... please give me the suggestion bro, how did u solved this issue,.. this Selected=true is disappering in countries dropdown list,....

please say the solution bro,..

im suffering from 3,4 days, not getting the solution

my gmail id : m19anand@gmail.com,...

please say the solution friends.....

hi,
just create an object of form collection.and using its object.we can get the selected value of dropdown list in the controller..
one example im givin below


C#
public Action result actionname(FormCollection frormobj)
{
 int variable = int.Parse(frormobj.GetValue("Country").AttemptedValue);
}

Hope this may help you..
 
Share this answer
 
v3
HI,

Yiu can also maintain by making an entity(Model) against the View.Then you dont want to make any code in your controller.just return the view with entity.

eg:

In Controller Action Method
If your EntityName is Credentials
public ActionResult Index(ClsCredentials ObjCredentials)
{
    return View(ObjCredentials);
}


In Your View Must Bind the Model.After that

<%: Html.DropDownListFor(Mdl => Mdl.Country,(SelectList)ViewData["Country"]) %>


Actually In MVC you should use Model.Formcollecton is an optional way if Model structure is not applicable in the related view
 
Share this answer
 
v3
Hi Boss,...


At present im facing the same problem as you,.... please give me the suggestion bro, how did u solved this issue,.. this Selected=true is disappering in countries dropdown list,....

please say the solution bro,..

im suffering from 3,4 days, not getting the solution
 
Share this answer
 

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