About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Stupid SharePoint Delimiters

I don't like SharePoint delimiters. They make me all sorts of mad. You really get into them when working with custom field types such as multi selection bound fields. They parse out as ";#". While that is all good for storage in SharePoint, sometimes programming against the field to pool values becomes a pain in the ass when writing WebParts or working on an arbitrary business application.

I needed a quick method to basically split on these this morning, so I threw this clunker together, which works fine. All it does is take the string parameter being passed in and use IndexOf against ";#" in order to return the first instance of the delimiter to get a starting point for the stripping. Once you have a the indexable numeric available to loop against, you can make two new strings that do the remove and replace functions, and then do all the returning.

C#:
  1. public static string[] RemoveAndReplaceFieldValue(string strFieldValue)
  2. {
  3. if (strFieldValue == null)
  4. throw new ArgumentNullException("strFieldValue");
  5.  
  6. int l_intIndex = strFieldValue.IndexOf(";#");
  7.  
  8. if (l_intIndex> -1)
  9. {
  10. string l_strRemove = strFieldValue.Remove(0, l_intIndex + 2);
  11. string l_strReplace = strFieldValue.Replace(";#" + l_strRemove, "");
  12. if (l_strRemove != null && l_strReplace != null)
  13. {
  14. return new string[] {l_strRemove, l_strReplace};
  15. }
  16. }
  17.  
  18. return new string[] { strFieldValue };
  19. }

Probably not ideal, however it sure is functional.

  • Share/Bookmark

1 Comment »

  1. Why not use one of the value types for the SPFieldControls (SPFieldLookupValue/SPFieldMultiChoiceValue)? They account for the delimiters, and allow you to get the values out with ease.

    SPFieldLookupValue splv = new SPFieldLookupValue(strFieldValue);
    string value = splv.LookupValue;

    Comment by Rich Finn — November 2, 2007 @ 10:55 am

RSS feed for comments on this post. TrackBack URL

Leave a comment