Create ListItems in an ASP.NET DropdownList
Traditional Loop Method
for(int i=0; i
You see it is inefficient. First it takes more lines of code. Second the loop increases as the item in the asp.net dropdownlist increases. The more efficient built in way is demonstrated below.
Display the Item Matched with Dynamic Input String
ddlTest.electedValue = ddlTest.Items.FindByValue(value).Value;
The dropdownlist now displays the item having value equal to "asp.net". I have only put an example. The high dynamicity of this technique is seen when you supply some dynamic value to the varibale value used in the example above.