Programmatically how to get the SharePoint Custom list/library choice values into dropdown list in SharePoint 2013.

Enter detail

And click on ok. Go to page to get the values into dd list. So this way you will get all the items into Drop down list programmatically.

Select year
Here is the code how to get choice values from SharePoint custom list/Library.

  1. private void BindYear()
  2. {
  3. SPWeb _web = SPContext.Current.Web;
  4. SPList list = _web.Lists.TryGetList("Listtitle");
  5. SPFieldChoice YearChoice = (SPFieldChoice)list.Fields["FieldName"];
  6. for (int i = 0; i < YearChoice.Choices.Count; i++)
  7. {
  8. ddlYear.Items.Add(YearChoice.Choices[i].ToString());
  9. }
  10. }
I hope this will help SharePoint beginners to get the values from Choice field programmatically.