This tutorial will explain how to bind List<T> to the listbox/dropdown list. Following are some simple steps to bind your listbox/dropdown list to List<T>.Step 1Create a List<T> in you code behind file i.e. .CS file. Following code shows how the List<T> of string is created. Months is a List<String> which stores a list of months in a year. ///Creating List of string for months. public static List<string> Months = new List<string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };Step 2After creating List<T>, bind List<T> with your listbox/dropdown list. The following code binds to dropdown and listbox too.//Binding list of string to listbox lst.DataSource = Months; lst.DataBind();
//Binding list of string to dropdown list drp.DataSource = Months; drp.DataBind();Output:When you run your application, the List<T> is bound to the listbox/dropdown list.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: