Check DropDown List contains a value in Asp.net ????
Oct
17
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 :--------
- if (dropdownlist1.Items.FindByValue("someValue") != null)
- {
- dropdownlist1.SelectedValue = "someValue";
- }
Wednesday, October 17, 2012 | Labels: Asp.net, Source_Code |
- Solved - "Are You Missing An Assembly Reference Error in Visual Studio"
- Binding Property Of Control From Other Control Using XAML in WPF
- Check DropDown List contains a value in Asp.net ????
- How to place cursor at the end and begining of the text in textbox??????
- How To Get Facebook Profile ID
- How To Create Disk Partition on Windows7
- Top 10 Tips To Improve System Speed
Total Pageviews
1082