sorting a drop down list populated from a data connection - InfoPath Dev
in

InfoPath Dev

Now you can find InfoPathDev on YouTube and Twitter!
Find Qdabra on Facebook

sorting a drop down list populated from a data connection

Last post 02-12-2009 01:07 AM by discodave82. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-01-2009 11:31 AM

    sorting a drop down list populated from a data connection

    I have a drop down menu being populated from a data connection bound to a sharepoint list. I need to sort the data in alphabetical order. The form will be used through the browser so I cannot rely on sorting the view (browser ignores default view sort order).

    I guess what I would want to do in this case is to pop each of these items off the data connection, put them into an array, do some sorting and then put them back into the drop down menu. Could I get some code pointers around getting the items from the data source into the array and then back into the drop down menu in sort order?

    I am under a bit of a deadline and I have spent a good amount of time on this already. Any help would be greatly appreciated!

  • 02-02-2009 02:50 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: sorting a drop down list populated from a data connection

  • 02-02-2009 03:47 AM In reply to

    Re: sorting a drop down list populated from a data connection

    Anuma,

    I have seen those before and have spent some time getting each to work. I was not successful with the first method and the second suggestion of using the url that generates xml will not work in my case because I cannot modify the data connections. Do you have any ideas on how to get this method to work successfully? I need to accomplish this in C# if the solution is a codded approach.

    XPathNavigator navigator = this.MainDataSource.CreateNavigator();
    XPathNodeIterator repeatingNodes = navigator.SelectChildren("XPath of your field", "Namespace of your form");
    ArrayList sortValues = new ArrayList();
    foreach(XMLNode repeatingNode in repeatingNodes)
    {
    sortValues.Add(repeatingNode.xml);
    }
    sortValues.Sort();

  • 02-02-2009 07:34 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: sorting a drop down list populated from a data connection

    Hello,

    Can you debug once and let us know what your error is? Where you are struck in that code?

    Are you able to add your xml nodes to sortValues?

    Do you want to just sort list or elements position by sorting order also? Can you give more details on your error?

  • 02-03-2009 01:15 PM In reply to

    Re: sorting a drop down list populated from a data connection

    I can suggest trying qRules, since it contains a command that allows you to sort without code.

    http://www.infopathdev.com/files/folders/dbxldownload/entry34534.aspx

     If you want more information about qRules do let me know.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 02-12-2009 01:07 AM In reply to

    Re: sorting a drop down list populated from a data connection

Page 1 of 1 (6 items)
Copyright © 2003-2010 Qdabra Software. All rights reserved.
View our Terms of Use.