Click here to Skip to main content
13,351,225 members (34,864 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have country in table and i want to bind country in dropdown but by default selected country is which is that user country in table...example suppose when i register that that time i was selected my country is india and when i login then in that dropdown all country fetch from database but by default selected country is 'india' how can i do????
plz help me.
Posted 19-Dec-12 18:32pm
Sachin Gargava 20-Dec-12 0:21am
what actually you want write little more clear.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When your question is both a paragraph and one sentence, the odds of you making sense, are low.

I think you're saying you want your drop down list to preselect the current value ? That's easy. The drop list has a selected value property. You can set it in your ASPX, or in your code behind.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

1. Bind your contry dropdown list with DataTextField = "CountryName" and DataValueField = "CountryId"
2. Fetch the user data
3. Once u fetch the data of selected user then write following line in your code behind file
ddlContry.Items.FindbyValue(usercontryid).Selected = true;
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If I am not wrong, You want the selected country of the User (What ever he had selected while registering himself).
What you have to do is very simple. Fetch data from your table and assign the value of your country dropdown with the value coming from database.

for ex

//write your query here
//after that Fetch data from database and fill dataset or datatable
//It's must to fill your Country Dropdown before assigning the selected value



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 |
Web02 | 2.8.180111.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2018
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