locked
how to split string values and bind to dropdownlist RRS feed

  • Question

  • hi we have string value:2;#ABC;#3;#DEF;#4;#GHI;#5;#JKL;#6;#MNO;#1;#PQR

    split that string and bind to Drop down list

    EX:

    ABC

    DEF

    GHI

    JKL

    MNO

    PQR

    Tuesday, April 8, 2014 10:39 AM

Answers

All replies

  • What's your question? Please next time insert question specifying your needs and scenario.

    This post [1] could be helpful for you to manage strings with the lookup formatting.

    [1] http://blog.qumsieh.ca/2009/01/08/working-with-the-spfieldlookupvalue-class-in-sharepoint/


     

    Marco Rizzi @Avanade Italy http://blog.marcorizzi.com

    Tuesday, April 8, 2014 10:46 AM
  • My Question is how to  Split string .

     string value1=2;#ABC;#3;#DEF;#4;#GHI;#5;#JKL;#6;#MNO;#1;#PQR

    i used this code it was working good

     string[] arrValue = val.Split("1,2,3,4,5,6,7,8,9,' ',;,#,' ',".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
    foreach (string s in arrValue)
    {
    //code here
    }


    Tuesday, April 8, 2014 12:20 PM
  • You should avoid string.Split. This is not the prefered way to do this.
    Instead you should use SPFieldLookupValue. Refere to: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldlookupvalue.aspx


    Tomasz von Oertzen-Groszewski - SOLVIN Information management GmbH
    Please click Mark As Answer; if a post solves your problem or Vote As Helpful if a post has been useful to you. This can help other community members reading the thread.


    Tuesday, April 8, 2014 7:48 PM