[CLOSED] ListItems / ComboBox - value is always a String?

  1. #1

    [CLOSED] ListItems / ComboBox - value is always a String?

    Hello,

    the ComboBox.Value is of type object, but when I get the value it is a string even though I do not put in a String then loading the Store.

    If you look at ComboBox.SelectedItem.Value, "Value" is of type String and that comes from the fact the SelectedItem is of Type ListItem, and ListItems Value-property is String.

    When I add data to my Store, that is by a ComboBox, I add an array of object[], like this:

      List<object> myStoreObjects = new List<object>();
                foreach (SomeObject cp2 in listOfObjects)
                {
                    myStoreObjects.Add(new object[] { cp2.Id, cp2.ObjectName });
                }
    The Id property is an uint, and ObjectName a string. This is the Store:

    <ext:Store ID="Store_SomeObjects" runat="server" AutoDataBind="true" AutoLoad="true" >
        <Reader>
            <ext:ArrayReader>
                <Fields>
                    <ext:RecordField Name="SomeObjectId" />
                    <ext:RecordField Name="SomeObjectName" />
                </Fields>
            </ext:ArrayReader>
        </Reader>
    </ext:Store>
    So I would like to get the uint back when I check what is selected in the ComboBox, but now I get a string. How do I get my real object? To convert string to uint is easy, but what if I have a complex custom object?

    Is it always gonna be String, and I have to parse that string (JSON??) somehow?

    Regards
    Ted
    Last edited by Daniil; Apr 09, 2011 at 12:47 PM. Reason: [CLOSED]
  2. #2
    Hi wagger,

    Could you clarify how do you imagine a Unit instance in client side JavaScript? There is no such class in JavaScript, you know.

    So, ArrayReader passes a Unit instance to client as a string: "100px", etc., but it doesn't remember the type of this instance.

    A .SelectedItem.Value comes from client side as a string.

    Please use Unit.Parse().
    Unit.Parse(this.ComboBox1.SelectedItem.Value)

Similar Threads

  1. Combobox Partial String Search for List Item
    By GolchK in forum 1.x Help
    Replies: 15
    Last Post: Jun 01, 2017, 11:51 PM
  2. [CLOSED] Can't add ListItems to ComboBox in codebehind [1.0]
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 18, 2012, 5:05 PM
  3. Replies: 2
    Last Post: Jul 12, 2012, 2:06 PM
  4. Custom Search ComboBox with String.Contains
    By BLOZZY in forum 1.x Help
    Replies: 0
    Last Post: Jan 28, 2011, 12:22 PM
  5. [CLOSED] adding listitems dynamically in a combobox
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 22, 2009, 4:26 PM

Tags for this Thread

Posting Permissions