[ASPX]
<ej:ListBox ID="Listbox1" runat="server" Width="200px"></ej:ListBox>
[CS]Code Behind
protected void Page_Load(object sender, EventArgs e)
{
//initilize the List of ListBoxItems to the variable
List<ListBoxItems>
list = new List<ListBoxItems>();
//then add the custom data's to the
list of items.
list.Add(new ListBoxItems() {
Text = "Item 1"});
list.Add(new ListBoxItems() {
Text = "Item 2" });
list.Add(new ListBoxItems() {
Text = "Item 3" });
list.Add(new ListBoxItems() {
Text = "Item 4" });
list.Add(new ListBoxItems() {
Text = "Item 5" });
list.Add(new ListBoxItems() {
Text = "Item 6" });
list.Add(new ListBoxItems() {
Text = "Item 7" });
list.Add(new ListBoxItems() {
Text = "Item 8" });
list.Add(new ListBoxItems() {
Text = "Item 9" });
list.Add(new ListBoxItems() {
Text = "Item 10" });
//map the corresponding field
this.Listbox1.DataTextField
= "Text";
//assign the collectiones to the
datasource property.
this.Listbox1.DataSource
= list; }
|