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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Check items in listbox on edit view.

Thread ID:





127502 Nov 20,2016 07:49 AM UTC Apr 3,2017 06:34 PM UTC ASP.NET MVC 5
Tags: ListBox
Bernard Jurlina
Asked On November 20, 2016 07:49 AM UTC

I have checked listbox in my edit view like this:

@Html.EJ().ListBox("lstCountry").Width("100%").Datasource((IEnumerable<SelectListItem>)ViewBag.lstCntry).ListBoxFields(lf => lf.Text("Text").Value("Value")).ClientSideEvents(e => e.CheckChange("onCheck")).ShowCheckbox(true).CheckItemsByIndex(Model.country_filter)

but it won't check items based on country_filter field, which is for example, "AT,AU,AZ".


Bernard Jurlina
Replied On November 20, 2016 03:46 PM UTC

Well, there is other method checkItemsByIndices, but it works with index values also. That's why my example won't work.
My listbox show values from countries list, lstCountry, for example, "AU" - "Australia"; "AT" - "Austria". How can I check items in listbox on edit view if I save "AU,AT" value in database?
That means that Austria and Australia has to be checked on edit.


Bernard Jurlina
Replied On November 20, 2016 11:10 PM UTC

Ok, I solved it.
In controllers ActionResult Edit I create a list, List<int> lstidx, and find indexes of save country marks with foreach loop....and forward it in ViewBag.
In edit view I use the ListBox like this:

@Html.EJ().ListBox("lstCountry").Width("100%").Datasource((IEnumerable<SelectListItem>)ViewBag.lstCntry).ListBoxFields(lf => lf.Text("Text").Value("Value")).ClientSideEvents(e => e.CheckChange("onCheck")).ShowCheckbox(true).CheckItemsByIndex(ViewBag.lstidx)

and it works.


Ezhil S [Syncfusion]
Replied On November 21, 2016 04:39 AM UTC

Hi Jurlina, 

Thank you for contacting Syncfusion support. 

We are glad that you were able to achieve the requirement. 
Please let us know if you need further assistance. 
Ezhil S 

Muhammad Usman
Replied On March 31, 2017 05:32 AM UTC

hello sir could you please provide me its implementation i will be very thankfull to you .All i need its controller action implementation
i want to implement it in mvc 5

Arun Palaniyandi [Syncfusion]
Replied On April 3, 2017 06:34 PM UTC

Hi Usman, 
Thanks for contacting Syncfusion Support.       
We have provided the sample below for your reference. 
If the shared sample didn’t meet your requirement, then please get back us more information that will help us provide a prompt solution. 
Arun P.   


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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