Get session variable and populate in dropdown list value as selected item or watermark

Greetings, 

I have a dropdown list where I select an item. Once I select the item, I moved to another page. The item is stored in a session object as follows: 

            Session["claimsSessionDetails"] = claimsSessions;
            var claimsSessionInfo = (ClaimsSessions)Session["claimsSessionDetails"];

I have my dropdown list component as follows: 

@Html.EJ().DropDownList("selectClaims").Datasource((IEnumerable<object>) 
ViewBag.datasourcex).DropDownListFields(df => df.ID("ClaimsId").Text("ClaimsFile").Value("ClaimsFile")).
WatermarkText(Claims.Resources.Resource.SwitchClaim )

What I want to achieve is that after I have moved to the next page, when I navigate to the previous page, I want the dropdown list to be populated with the selected item that I have selected prior moving to the next page. 

Could someone please advise how to achieve this via javascript ? 

Thanks & Regards,

1 Reply

KR Keerthana Rajendran Syncfusion Team January 25, 2018 10:36 AM UTC

Hi Nash Raja,   
   
Thank you for contacting Syncfusion Support.   
   
We suggest you to set enablePersistance property of DropDownList to true, so that the selected items will be maintained in dropdownlist even after navigation. Please refer to the below code   
   
@Html.EJ().DropDownList("selectClaims").Datasource((IEnumerable<Countries>)ViewBag.datasourcex).EnablePersistence(true).DropDownListFields(f=>f.Text("text").Value("id"))   
   
We have prepared a sample for your reference which can be downloaded from the following link   
   
   
Also, refer to the below UG for more details   
   
   
Regards,   
Keerthana.  
 


Loader.
Up arrow icon