Loading an ASP.NET DropDownList

From the examples below showing loading DropDownList in ASP.NET, which method is preferred and why?

Method 1:

Create an array of objects ListItemloaded with entity information, and use the method DropDownList.Items.AddRangeto load the list.

Method 2:

Create a collection of entity objects BindableList<T>and use the method DropDownList.DataSourceto load the list.

Method 3:

Create a collection of entity objects List<T>and use the method DropDownList.DataSourceto load the list.

Thanks in advance.

+3
source share
1 answer

All methods are similar for the drop-down list, but have their pros and cons. Here are some short answers:

1 . 1, ​​, , .

: , ListItems. - ListItem, .


2 , TwoWay. asp.net , .

: , BindableList IEnumerable, , DataBind.


3 , , .net.

: , Method2, List IEnumerable, , DataBind.

+5

Source: https://habr.com/ru/post/1773734/


All Articles