[CLOSED] ComboBoxFor doesn't show description after page loads ...

  1. #1

    [CLOSED] ComboBoxFor doesn't show description after page loads ...

    Hi,
    how can I get the the ComboboxFor get to show the corresponding
    description values.
    In this case, 1 -> M, 0->W ?

    Regards,
    Holger
                                                        Html.X().ComboBoxFor(m => m.ES_VERS_GESCHLECHT)
                                                        .ID("combo_ES_VERS_GESCHLECHT")
                                                        .Width(40)
                                                        .LabelAlign(LabelAlign.Top)
                                                        .FieldLabel("Geschlecht")
                                                        .Editable(true)
                                                        .Items(l1items =>
                                                        {
                                                            l1items.Add(
                                                                Html.X()
                                                                .ListItem()
                                                                .Text("M")
                                                                .Value("1")
                                                            );
                                                            l1items.Add(
                                                                Html.X()
                                                                .ListItem()
                                                                .Text("W")
                                                                .Value("0")
                                                            );
                                                        })
    Last edited by geoffrey.mcgill; Nov 08, 2012 at 3:30 AM. Reason: [CLOSED]
  2. #2
    Hi Holger,

    I tested, it works as expected for me.

    Here is my test case.

    View
    @model Ext.Net.MVC.Examples.Areas.Models.Model_BindModel
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    
        @(Html.X().ComboBoxFor(m => m.ComboValue)
            .Items(
                Html.X().ListItem().Text("M").Value("1"),
                Html.X().ListItem().Text("W").Value("0")
            )
        )
    </body>
    </html>
    Model
    public class Model_BindModel
    {
        [Field(FieldLabel = "ComboBox 1")]
        public ListItem ComboValue
        {
            get;
            set;
        }
    }
    Controller Action
    public ActionResult Index()
    {
        return View(new Ext.Net.MVC.Examples.Areas.Models.Model_BindModel() 
            { 
                ComboValue = new ListItem() { Value = "1" } 
            });
    }
  3. #3
    I found out, that if the values are
    String
    Values, it works.
    But for all
    int
    values, it doesn't work.
    The page is bound to the model via entity framework.
    And the selected values ('1' for 'M') get transmitted to the database
    correctly.
    Doesn't this work for int values ??

    Regards,
    Holger
  4. #4
    Please set Mode="Raw" for ListItem
    or use the following code
    .Items(new {
         W = 0,
         M = 1
    })

Similar Threads

  1. ComboBoxFor and empty value after load
    By zwf in forum 2.x Help
    Replies: 1
    Last Post: Nov 12, 2012, 1:46 PM
  2. Replies: 0
    Last Post: Feb 06, 2012, 7:29 PM
  3. Replies: 0
    Last Post: Apr 04, 2011, 6:05 PM
  4. Replies: 2
    Last Post: May 05, 2010, 10:23 AM
  5. [CLOSED] Display modal while grid/page loads
    By bfolger in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 26, 2009, 7:05 PM

Posting Permissions