Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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
Edited 2-Jan-13 21:28pm
v2
Comments
prashant patil 4987 at 3-Jan-13 3:29am
   
can you clear your question in detail?
Sampath Kumar Sathiya at 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 at 3-Jan-13 5:28am
   
+5
Zoltán Zörgő at 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 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
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ő at 3-Jan-13 3:47am
   
Wroooo, brother...! It would be nice to change a little bit more, before using my answer...
Turbo_23 at 3-Jan-13 3:52am
   
but bro i think this is the correct & use friendly way....isn't it :-)
ridoy at 3-Jan-13 5:28am
   
+5
Turbo_23 at 3-Jan-13 5:32am
   
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 430
1 Gihan Liyanage 347
2 ClimerChinna 222
3 vikinghunter 176
4 OriginalGriff 151
0 Sergey Alexandrovich Kryukov 8,373
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,025
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 3 Jan 2013
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