Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Every One,

I am working in asp.net website. On Page load i am filling country dropdownlist with all countries name. after that i have a search panel.
in this when i select a username. then i want to select user's country name in dropdownlist.
so give me any idea how can i do this?
please give me any link or any solution.
Posted

when i select a username. then i want to select user's country name in dropdownlist.
Best and to be sure, it you need to capture the country of user when they register.
Thus, on login, you have details of the user captured earlier. Set the dropdown value of country as per captured earlier.

So steps:
1. While registering a username, capture country along with other details if any
2. At the time of login, find the country associated with the username
3. Use the country found for the username to set it in country dropdownlist

Try!
 
Share this answer
 
Comments
coolnavjot31 4-Jul-12 2:09am    
Thanks for reply,

But i found the solution of this. code is following

ddlCountry.SelectedIndex = ddlCountry.Items.IndexOf(ddlCountry.Items.FindByValue(countryname));

countryname is value which i want to set in dropdownlist.
Sandeep Mewara 4-Jul-12 2:24am    
I said the same thing! You have to have countryname somewhere, right?
coolnavjot31 4-Jul-12 3:03am    
yes you said which i asked. means theoretically you explained my question in your wording but i wanted the code to do this.

Thanks for your reply to me....
bbirajdar 4-Jul-12 2:30am    
+5 .. for understandung the question
i found the solution of this. code is following:

C#
ddlCountry.SelectedIndex = ddlCountry.Items.IndexOf(ddlCountry.Items.FindByValue(countryname));

countryname is value which i want to set in dropdownlist.
 
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