none
TreeView in Visual WebPart not displaying correctly

    Question

  • I have a TreeView control in a Visual WebPart that is displaying several fields from SharePoint lists. On a few of the nodes, the text is being displayed with leading characters like "5;#" (ignore quotes). The remaining nodes are OK. The only difference that I can see between the nodes is that the fields with the problem are either lookup fields or system names (i.e. people picker). The codes appear to be the IDs of the items in the original list.

    Doss anyone know how I can display these values as text without the leading characters?

    I encountered this in Lab 03 of the 10175A SharePoint Developer course.

    Tuesday, November 05, 2013 8:26 AM

Answers

  • Hi,

    Chose any one of the below option to resolve your problem.

    • Just split the text using the leading special characters and display it.
    • Use Ensureuser object to convert the user name correctly and for lookup columns use the split as we know that the special characters are not going to change

    Regards,


    Sairam Avacorp Technologies

    • Marked as answer by SP_Farmboy Tuesday, November 05, 2013 9:09 AM
    Tuesday, November 05, 2013 8:33 AM

All replies

  • Hi,

    Chose any one of the below option to resolve your problem.

    • Just split the text using the leading special characters and display it.
    • Use Ensureuser object to convert the user name correctly and for lookup columns use the split as we know that the special characters are not going to change

    Regards,


    Sairam Avacorp Technologies

    • Marked as answer by SP_Farmboy Tuesday, November 05, 2013 9:09 AM
    Tuesday, November 05, 2013 8:33 AM
  • Sairams,

    Thanks for the quick reply. If, by "split", you mean use a substring, then that certainly works.

    Here's what I used (zoom to view):

    and here's the result:

     

    Good stuff. Thanks again!


    • Edited by SP_Farmboy Tuesday, November 05, 2013 9:31 AM
    Tuesday, November 05, 2013 9:09 AM
  • Substring(3) will work only for the numbers that between 0 - 9 meaning 1;# till 9;# once you get a 2 digits (10;#) you will have wrong results. When i say about split its like this

    TreeNode applicant = new TreeNode(item["Applicant"].ToString().Split('#')[1])

    Regards,


    Sairam Avacorp Technologies

    Tuesday, November 05, 2013 10:23 AM
  • Sairam,

    Even better; thanks very much for the explanation. I'm learning something every time I visit this forum!

    Steve

    Tuesday, November 05, 2013 5:00 PM