For asp.net dropdownlist, both of the below lines of code achieve the same thing. The only difference I see is one is shorter than other. Is there a specific advantage of using one over the other other than code readability?
ddl.SelectedValue = 5;
vs.
ddl.Items.FindByValue(5).Selected = True;
Both items do most of the same things; however, the second line, if no item is found, will throw an exception:
ddl.Items.FindByValue(5) //may return null..
.Selected = True; //throws NullReferenceException
Whereas selectedvalue doesn't provide that hassle.