C# should fill IP DropDownList - InfoPath Dev
in

InfoPath Dev

C# should fill IP DropDownList

Last post 12-07-2006 04:52 PM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-06-2006 09:26 AM

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    C# should fill IP DropDownList

    I'm using InfoPath 2007 and MOSS 2007 Forms Server. I've one combo box that should be filled with the column names (NOT values in this column) of another MOSS' list.

    Unfortunately I haven't found any way in IP to do this. Is there a way?

    That's why I want to do this with C# using the SP object model. It's easy to alter simple text boxes but a DropDownList seems to be more complex as the displayed and selected values are not stored in one place!?

    I've tried something like this:


    XPathNavigator root = this.MainDataSource.CreateNavigator();
    XPathNavigator ddl = root.SelectSingleNode("//my:dropdownlist", this.NamespaceManager);
    ddl.SetValue("first value");


    But this doesn't work!

    Thanks in further for any help!
  • 12-06-2006 02:33 PM In reply to

    Re: C# should fill IP DropDownList

    You don't alter any "control" in InfoPath -- only DOM nodes.

    Set up your drop-down list to populate based on your MOSS list. Then when list is updated, your drop-down choices will automatically be updated.

    If this is not possible, create a secondary data source and point your drop-down list at that. Then use code to add or remove nodes from that data source. The repeating list of nodes will be the options your drop-down list displays.
  • 12-07-2006 07:00 AM In reply to

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    Re: C# should fill IP DropDownList

    quote:
    You don't alter any "control" in InfoPath -- only DOM nodes.



    Yes, that's right. But a control is in a DOM node, isn't it? This node should be altered. For textboxes this is not a problem, and I thought it might be as easy in the case of dropdown lists - but it isn't.

    For textboxes one simply writes:


    XPathNavigator root = this.MainDataSource.CreateNavigator();
    XPathNavigator name = root.SelectSingleNode("//my:name", this.NamespaceManager);
    name.SetValue("XXXXXXXXXXXXXXX");


    and I thought there's a similiar way to alter DDLs?

    quote:

    Set up your drop-down list to populate based on your MOSS list. Then when list is updated, your drop-down choices will automatically be updated.


    This is not possible because I don't want the content of the list in my DDL. I just want to have a DDL with the names of the columns of a MOSS list.

    quote:

    If this is not possible, create a secondary data source and point your drop-down list at that. Then use code to add or remove nodes from that data source. The repeating list of nodes will be the options your drop-down list displays.



    I can't create a data source that points to nothing. IP wants always a distinct target. Should I choose something arbitrary and modify the .xsd file later? Are resource files in this context a possible way?
  • 12-07-2006 04:52 PM In reply to

    Re: C# should fill IP DropDownList

    Again, you only modify nodes and node values -- not controls. When dealing with a DDL, you are dealing with the node that the DDL control is "bound" to--not the control itself. Thus if you modify the value of that node that your DDL is bound to, you modify the selected value of that DDL.

    What you need to do is create a secondary data source (i.e. an XML file) that has a repeating list in it... something like:

    <ColumnNames>
       <ColumnName/>
       <ColumnName/>
    </ColumnNames>

    Create a new data connection to this XML file. Then set up your drop-down list control to get its values from this new data connection.

    Okay, now your drop-down list will have two blank values in it. Why did I list ColumnName twice? So that the auto-generated schema will list that node as repeating.

    With this all in place, now you must write some code to delete the two default blank ColumnName nodes from your data connection, and the add in ColumnName nodes populated with the names of your MOSS list columns. Once you've inserted a ColumnName node for each actual column, populated with the name of said columns, then your drop-down list will correctly display the column names in the DDL.

    The node you bind your DDL control to is the node that will contain the user's selected value.

    I hope that helps to clarify the process.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.