Showing posts with label Set Picklist option value. Show all posts
Showing posts with label Set Picklist option value. Show all posts

Saturday, January 8, 2011

Programmatically set Picklist Option value in CRM Entity Item

In my older post I have collect Picklist options in DropDownList.
So now I save this DropDown’s selected value in CRM’s Entity Item’s Attribute.
You can’t save option in Entity Item, without picklist’s Value & Text. Means you have to provide Option’s Value & Options Text.
Also you have to create a new instance of the picklist before setting the value.
See the below sample code snippet for set the picklist option value.


CrmSdk.new_customentity newcustomentity = new CrmSdk.new_customentity();//Custom Entity's obj

newcustomentity.new_entityattribute = new CrmSdk.Picklist();//Creating New Instance before assign Value & Text
newcustomentity.new_entityattribute.Value = Convert.ToInt32(objDropDownList.SelectedItem.Value); //Set DropDownList's Value
newcustomentity.new_entityattribute.name = objDropDownList.SelectedItem.Text;//Set DropDownList's Text


Happy Coding!!!