I am pretty new in**.NET** and moreover in SharePoint and I have the following problem working on a SharePoint 2013 project.
Into my code I do:
for (int i = 0; i < eitchettaCorrenteList.Items.Count; i++)
{
string valoreColonnaIniziativaInternalName = eitchettaCorrenteList.Fields[nomeColonna].InternalName;
string valore = eitchettaCorrenteList.Items[i][valoreColonnaIniziativaInternalName].ToString();
}
I am iterating on a SharePoint list named etichettaCorrentList and, for each row, retrieving the value of a specific field.
It works bu the problem is that this line:
string valore = eitchettaCorrenteList.Items[i][valoreColonnaIniziativaInternalName].ToString();
returns a strange value that contains the expected value (the one contained in my list) preceded by a code that is not part of the value of the selected field, something like: string;#S01-INIZIATIVA EUROPA 1 TEST
What is this string;? Why am I retrieving it? How can I correctly remove or not obtain this string; before the desired information? What is wrong? What am I missing?
ToString()
. There are many different field types, including lookups (which store both ID and text), pictures, multi-value text fields and lookupts etc. The way you wrote the code you are retrieving the internal data. - Panagiotis KanavosString strPrice = priceField.GetFieldValueAsText(item["Retail_x0020_Price"])
Source: docs.microsoft.com/en-us/previous-versions/office/developer/… - Cleptus