BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Jorge ,
Thank you for contacting Syncfusion support.
Query: Form the ListBox items from the code behind.
We have analyzed your query that you have added the items to
the ListBox component in dynamically from the code behind. To add the multiple
items to the ListBox component, initially need to declare the variable with
List of ListBoxItems type. Then add the new data’s to this declared variable.
After initialization of new data’s to the items can be
assigned to the ListBox component datasoure property and its corresponding
field need to map.
We have achieved your requirement of add the new items to
the ListBox components by refer the below code snippet.
[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; }
|
Please let us know if you need any further assistance.
Regards,
Kalpana K