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.

Check items in listbox on edit view.

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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".

Thanks!
B.



Bernard Jurlina
Replied On November 20, 2016 10:46 AM

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.

Thanks!
B.

Bernard Jurlina
Replied On November 20, 2016 06:10 PM

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.

B.

Ezhil S [Syncfusion]
Replied On November 20, 2016 11:39 PM

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. 
 
Regards, 
Ezhil S 


Muhammad Usman
Replied On March 31, 2017 01:32 AM

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 02:34 PM

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. 
 
Regards,   
Arun P.   


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.

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.

;