I have a list A with field SAP (radiobutton datatype). It has 3 values SAP-FSL, SAP NXP and both. I need to display these 3 values in webpart as radiobutton provided in image. It will be dynamic, in future if we want to add new radio control in webpart we just want to add new value in fields SAP. How to achieve this. Please help with c#. Thanks.
SPFieldChoice field = (SPFieldChoice)spList.Fields[fieldName];
List<string> fieldList = new List<string>();
foreach (string str in field.Choices)
{
fieldList.Add(str);
}
where spList is SPList object.
fieldList contains the choice fields value. Using these values, you can bind your radio-button list.
-
Just curious; stopped doing C# a long time ago.. isn't there a map function so you can do
field.Choices.map(=>str)
instead of that foreach loop? – Danny '365CSI' Engelman Apr 27 '17 at 10:14 -
@Danny'365CSI'Engelman, for mapping you can refer sharepoint.stackexchange.com/questions/25442/… link. – Divya Sharma Apr 27 '17 at 10:39
-
No I meant the Functional Programming term
map
, found it in MSDN: msdn.microsoft.com/en-us/library/bb548891.aspx – Danny '365CSI' Engelman Apr 27 '17 at 11:01 -