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. Image for the cookie policy date

Data Source for List Box

Im working on asp.net mvc , I have a viewmodel that return array of strings  from controller and I want to bind this array with LISTBOX control in view page
I return to the following site 
and go to listbox control I did't find any member that related to data source
so, can you help me please

1 Reply

TH Thivya Syncfusion Team May 7, 2013 04:23 AM UTC

Hi Yara,

Please find the below code snippets to bind the array of string as datasource to the Listbox control.

[Controller]

public ActionResult Demo()
{
List<string> data = new List<string>() { "Item1", "Item2", "Item3" };
return View(data); // passing data source to the listbox
}

[View]

@model
IEnumerable<string>

@Html.Orubase().ListBox("Incidents").RenderMode(RenderMode.Auto).IOS(c => c.ShowCorners(false)).BindDataSource(Model, map =>
{
map.MapTo<string>(binding =>
{
binding.ItemDataBound((item, nd) =>
{
item.Text = nd;
});
});
})

Also we have created sample and attached in the below link for further reference.

ListBoxDataSource.zip

Please try this and let us know if it helps.

Regards,
Thivya.


Loader.
Live Chat Icon For mobile
Up arrow icon