Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai
In my web application,i will bind data in dropdownlist and make one values as selected value from list,selected value appear in drop down box,if i click down arrow from drop down, selected value appear in list also(i.e)2 times appear in drop down one in drop box and another one in list ,my need is how to remove that value from list,bcz selected value show in top.

Is it possible,pls reply if not possible also.like cant do....
pls reply asap

Regards
AravindB

EDIT
-----------------
thank u for ur reply.i will use drop down list ,i will bind data in dropdown and i selecte one value from dropdownlist,after select at top selecet value appear and also in the list also value appear,my need is after selecte value ,only show on top and remove form list in same dropdown list box
Posted
Updated 7-Jan-14 21:11pm
v3
Comments
Zahid Khan Kakar 8-Jan-14 0:59am    
Your questions is not that much clear for understanding, can you post some code please.
Aravindba 8-Jan-14 1:05am    
thank u for ur reply.i will use drop down list ,i will bind data in dropdown and i selecte one value from dropdownlist,after select at top selecet value appear and also in the list also value appear,my need is after selecte value ,only show on top and remove form list in same dropdown list box
Please post your code.
Aravindba 8-Jan-14 4:20am    
i am need code,so only i ask here,for binding data in dropdown ,basic one,so we all know that coding,my need is how to hide selected value from dropdownlist bcz it appear in dropdownbox(at top)and in ie10 behave what i need,i.e if selected value is last,when i click down arrow list appear at the top of dropdownbox,if it is first,list popup down like ordinary,if it middle or near to middle half of the value top and other half down and selected value in the middle.IE10 behave in different way,i.e not always show list below dropdownbox.
JoCodes 8-Jan-14 3:49am    
Update your question with the code tried so that it will be easy to help you.

use this 
There is a property for item that will be by default selected
and another property AppendDataBoundItems=true



C#

"><asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" >
<asp:ListItem Text ="Volvo" Value ="1" Selected ="True" ></asp:ListItem>
<asp:ListItem Text ="Maruti" Value ="2"></asp:ListItem>
<asp:ListItem Text ="Swift" Value ="3"></asp:ListItem>
</asp:DropDownList>
 
Share this answer
 
If I understand correctly, this is what you want:
A drop down has values 1, 2, 3, 4, 5
First time, you click on down arrow of the drop-down, it shows all values in the list.
You select 4.
Now again you click on down arrow of the drop-down, it shows 4 as the selected value.
What happens now: shows value 1, 2, 3, 4, 5 in list
What you want to do:show values 1, 2, 3, 5 in list. Get rid of 4 from the list, just because it's selected.

My solution:
What you want to do is not the standard behaviour of drop down control. Not to mention, it will just confuse the users.
You can not do it, because if you remove it from the list, it can not be selected.

XML
In ASP drop down, as far as I know, it can not be done. I found a work-around in html drop down. See if that helps you. As I change the format from drop-down to list and list to drop-down in these two button clicks, may be you can do that on click. Sorry, can not post better example as I'm running out of time.

<select id="T">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
    <input type="button"  önclick="T.multiple = 'multiple';" value="b1" />
    <input type="button"  önclick="T.multiple = '';" value="b2" />
 
Share this answer
 
v2
Comments
Aravindba 8-Jan-14 4:14am    
Thank u for ur reply.in IE10 only like this way work,i mean,selected value show only one time in dropdown box,when i click down arrow.pls use ie10 and check drop down values
anuradha.sardesai 8-Jan-14 4:56am    
See the updated solution
Aravindba 8-Jan-14 5:40am    
thank ,just u update ie10 browser and check this link ,same link check in chrome and mozila,then only u find different.in that page click dropdown arrow and see diff.
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_value
anuradha.sardesai 8-Jan-14 21:47pm    
@arvindba did you get a chance to run the code (simple JS) in browser? It gives the effect you want.
Aravindba 8-Jan-14 23:47pm    
did u check in ie10 ,this link http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_value
write your dropdown fill code in is post back condition As i call fillDropdown function in example below .

VB
If Not IsPostBack Then
   FillDropdown()
       End If
 
Share this answer
 
Comments
Aravindba 8-Jan-14 4:54am    
what puorpose use FillDropdonw() function ?pls read questions and reply,i did bind data in dropdown

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