We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can not get selected value in dropdownlist with checkbox

Thread ID:

Created:

Updated:

Platform:

Replies:

120121 Sep 2,2015 07:42 AM UTC Sep 3,2015 11:54 AM UTC ASP.NET MVC 1
loading
Tags: DropDownList
Manolo
Asked On September 2, 2015 07:42 AM UTC

Hi,

I've a dropdown list with checkBox, similar at this

Class:

public partial class TipoOS
    {
        public TipoOS()
        {
            CodigoOS = new HashSet<CodigoOS>();
            SubtipoOS = new HashSet<SubtipoOS>();
        }

        public int ID { get; set; }

        [Required]
        [StringLength(150)]
        public string Nombre { get; set; }

        [StringLength(250)]
        public string Descripcion { get; set; }

        public virtual ICollection<CodigoOS> CodigoOS { get; set; }

        public virtual ICollection<SubtipoOS> SubtipoOS { get; set; }
    }

View:
@using (Html.BeginForm("CrearInformes","InformeDiario"))
{              
                <div class="col-md-2">
                    @Html.EJ().DatePicker("FechaInforme").DateFormat("dd/MM/yyyy").Value("17/07/2015").Locale("es-ES")
                </div>
                <div class="col-md-2">
                    @Html.EJ().DropDownList("TipoOperacion").Datasource((IEnumerable<EntitiesInforme.Informe.TipoOS>)ViewBag.DSTiposOperacion).DropDownListFields(ddl => ddl.ID("ID").Text("Nombre").Value("ID")).ShowCheckbox(true)
                </div>               
                <div class="col-md-2">
                    <button type="submit" class="btn btn-default">Generar Informe</button>
                </div>
}

My controller:

 public ActionResult CrearInformes(DateTime? fechaInforme, List<object> tipoOperacion)
{          
            return View();
}



In list "tipoOperacion", I get the Name of selected values, not the ID.

What is wrong?

Thanks

Sasikala Nagarajan [Syncfusion]
Replied On September 3, 2015 11:54 AM UTC

HiManolo,

Thanks for contacting Syncfusion support.

We have analyzed your query (able to get name in post back not id) and unable to reproduce the reported issue at our end. In form post back, we are able to get the ID of the selected items since we mapped the data source’s empidfield to dropdown list value fields. Please refer to the below sample prepared based on the provided code.

Sample: http://www.syncfusion.com/downloads/support/forum/120121/autocomplete_(4)-626656692.zip


In this sample, we have mapped theempidfield of local data source to dropdown list value field (member of DropDownList fields’ property). In form post back we can get the selected item’s id.

Please refer to the below code example:


@Html.EJ().DropDownList("TipoOperacion").Datasource((IEnumerable<object>)ViewBag.datasource).DropDownListFields(ddl => ddl.ID("empid").Text("firstname").Value("empid")).ShowCheckbox(true)


If you are still facing the problem, please revert us with issue reproduced sample that will be helpful for us to analyze further and provide solution.

Regards,

Sasikala Nagarajan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;