Hi!
I have two questions.
(1)
I can't figure out how to initialize an empty ListBox. I do not want it to be bound to a datasource at all, as I will be adding items dynamically (both through client side js and server side C#).
My code in the .aspx file is as follows:
<ej:ListBox ID="AthleteListBox" Width="95%" AllowMultiSelection="true" LoadDataOnInit="false" DataValueField="Value" DataTextField="Text" runat="server">
</ej:ListBox>
and I would like it to create a list box with no list items in it. Instead, I get this error: "DataSource/Target list must not be empty at initial load since ListBox is generated from dataSource/target items." If I add in an Items section with at least one ListBoxItems, the box works fine, but I need it to have zero items. I was hoping setting the LoadDataOnInit property to false would solve the problem, but it doesn't seem to have done anything.
(2)
I can't figure out how to add a list item with both text and value using javascript. I can add items fine from the codebehind, but when I try to add from the client side, I can only successfully add an option with text. I have tried adding an item as follows:
var item= new Object();
item.Text= "Item Text"
item.Value= "Item Value"
listBox.ejListBox("addItem", item);
But I only end up with an empty list item.
I can successfully add a list item with text by doing the following:
listBox.ejListBox("addItem", "Item Text");
, but I also need the list item to have a value property.
Thanks for your help!
Emily