Set the OptionsetValue in MS CRM from Asp.Net WebSite with C# Code

Set the Optionset value in your custom entity in MS CRM 2011 try the below code

protected void btnSubmit_Click(object sender, EventArgs e)

IOrganizationService service = PCI.GetOrgService();

Entity Doctor = new Entity(“new_doctor”);
if (DropDownList1.SelectedItem.Value != “0”)
Doctor[“new_specialization”] = new OptionSetValue(int.Parse(DropDownList1.SelectedItem.Value));


catch (Exception ex)

throw ex;


If it is a Create new record

Guid newDoctorId = service.Create(Doctor);

Happy Coding..



Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s