code gives you SPFieldLookupValueCollection in array format

SPFieldLookupValueCollection fieldValues1 = new SPFieldLookupValueCollection();
foreach (Control ctrl in PnlProfileTags.Controls)// Form Control Id
{
    CheckBox cb = ctrl as CheckBox;
    if (cb != null)
    {
        if (cb.Checked)
        {
            int TageID = Convert.ToInt32(cb.ID.Substring(4));
 var TagItm = web.Lists[listTags.Title].GetItemById(TageID);
 fieldValues1.Add(new SPFieldLookupValue(TagItm.ID, TagItm.Title));
         }
     }
 }
List<string> strValues = new List<string>();
 foreach (var item in fieldValues1)
 {
     strValues.Add(item.ToString().Split('#')[1]);
 }

 string[] ProfiletagformValue = strValues.ToArray();// output 0 SharePoint
                                                              1 Dotnet

                                                              2 Hr          

Comments

Popular posts from this blog

My Interview Experience

React Checkbox Control SPFx