Click here to Skip to main content
13,139,254 members (86,248 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
in dropdown list i have use list item. in list item i have to put 'please select' at first list item and this will not be consider as data.then how to do this?
Posted 2-Jan-13 21:27pm
Updated 2-Jan-13 21:28pm
v2
Comments
prashant patil 4987 3-Jan-13 3:29am
   
can you clear your question in detail?
Sampath Kumar Sathiya 3-Jan-13 3:35am
   
You need check the selected index and avoid that.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

<select name="dropdown" id="dropdown">
 <option value="" selected disabled>Please select</option>
 <option value="value1" >Value 1</option>
 <option value="value2" >Value 3</option>
</select>


Please note the disabled attribute. Browsers should not allow this to be selected. But if, you can check in code (either on client side and/or server) the empty value.
  Permalink  
Comments
ridoy 3-Jan-13 5:28am
   
+5
Zoltán Zörgő 3-Jan-13 5:31am
   
Thank you.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

I think while validating the DropDownList you are getting problem, right? If yes then go to the RequiredFieldValidator controls, which you are using to validate the DropDownList and set the InitialValue of the RequiredFieldValidator as "please select" . This will avoid your selection if you have selected "please select" item from your DropDownList and make sure the value for that listitem is "please select".

Check more referances Here[^].


--Amit
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hi,

<select name="dropdown" id="dropdown">
 <option value="-1">Please select</option>
 <option value="value1" >Value 1</option>
 <option value="value2" >Value 3</option>
</select


Use asp required field validator with "initial value=-1", to restrict user to select "please select".
  Permalink  
v2
Comments
Zoltán Zörgő 3-Jan-13 3:47am
   
Wroooo, brother...! It would be nice to change a little bit more, before using my answer...
Turbo_23 3-Jan-13 3:52am
   
but bro i think this is the correct & use friendly way....isn't it :-)
ridoy 3-Jan-13 5:28am
   
+5
Turbo_23 3-Jan-13 5:32am
   
thanks
Praveenpk3 4-Dec-14 8:07am
   
+5 !
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

just use an if clause

something like this

If ddl.SelectedText = "Please Select" then
  msgbox "Invalid Selection"
  End
Else
   'Put in your code here
End If
  Permalink  
v2

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 |
Web03 | 2.8.170915.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2017
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