Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET SQL VB.NET
Hi,
 
I have a column name is Country_nm in table like
 
China
India
USA
JAPAN
 

I want to show these country_nm in dropdownlist control but I want to show India as the name in dropdownlist and then others will be shown usin select query
like
India,
China,
Japan,
USA
 

Please help me...
Posted 4-Dec-12 19:23pm
Comments
choudhary.sumit at 5-Dec-12 1:28am
   
insert india at 0 index of the dropdown. dont fetch it from database..
n_sriganesh at 5-Dec-12 2:17am
   
Do you have any columnid or any other column associated with this column.for e.g
countryid country_nm
1 china
2 usa
etc etc
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add a sort column to your data source with India in position 0
or
Manually insert India to your list and then do all the other countries in your data source remembering no to process India twice.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this....
 
<asp:listitem text="India" value="0" xmlns:asp="#unknown">
<asp:listitem text="Usa" value="1">
<asp:listitem text="china" value="2">
<asp:listitem text="japan" value="3">
 
or
 
in code behind
 
ddl_country.items.insert(0,"India");
 
ddl_country.items.insert(1,"japan");
 
.......
</asp:listitem></asp:listitem></asp:listitem></asp:listitem>
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

select * from country_lst_tab
order by case when Country_nm='India' then 0 else 1 end, country_nm
  Permalink  
Comments
Archana Parate at 29-Jan-13 5:44am
   
Thank You...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

you can use selectedindex/selectedItem property of listbox/dropdown to set default selected value.
  Permalink  

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 235
1 OriginalGriff 215
2 Manfred R. Bihy 190
3 CHill60 180
4 _Amy 155
0 OriginalGriff 7,395
1 Sergey Alexandrovich Kryukov 6,163
2 Maciej Los 3,754
3 Peter Leow 3,448
4 CHill60 2,702


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2014
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