umbraco : How to retrieve drop down value and drop down text in umbraco using c#.

We have some scenario where we want to fetch custom umbraco dropdown list field value and text. For Instance consider situation where you have defined prevalue A, B, C, D in umbraco dropdown list data types and you want to retrieve user selected value from code behind.

See Below Image

CustomDrop-downList

demodropdownlist used in demoDropdown document type as property data type.

documentType

Now In code Behind file we can retrieve user selected value. In content section it look like

content-section

In code behind file we can retrieve user selected value text I mean A, B, C, D or it’s value.

 // Define content node ID in which dropdown data type has been used
 int contentNodeID = 1200;
 Document docDropDown = new Document(contentNodeID);

// Retrive Prevalue of selected value
 int selectedPreVal = Convert.ToInt32(docDropDown.getProperty("dropdownabcd").Value);
 [/sourcecode ]

// Retrive corresponding Text value corrospond to prevalue
 string selectedTextVal = umbraco.library.GetPreValueAsString(selectedPreVal);
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s