Check DropDown List contains a value in Asp.net ????

I am quite sure, that u all wondering that what a foolish type of post is this bcoz i know that atmost all of you can do this, but i am sure the way to do this provided by me is surely effective then the way that you all have used.....I have seen many people write good coding, but, sometimes they don't pick efficient way to do somethings. When we do code reviews we can identify some code parts are very simple to implement but they implement it in a complex way, want to correct them. A simple scenario is, how to check a drop down contains a value. Some people are looping through all items and finding the item exists or not. Some people are doing some complex logic etc. But, below is what  believe the good and simple way of finding a value is in drop down list of items :--------


  1. if (dropdownlist1.Items.FindByValue("someValue") != null)    
  2. {    
  3.    dropdownlist1.SelectedValue = "someValue";    



Total Pageviews