populate dropdown during OnLoadEvent - InfoPath Dev
in

InfoPath Dev

populate dropdown during OnLoadEvent

Last post 08-30-2006 01:16 PM by Greg Collins. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-17-2006 11:29 PM

    populate dropdown during OnLoadEvent

    Hi,

    I want to populate a dropdown list when the form is openend. The values should appear depending on a select from a database, e. g. only rooms which are not booked should appear in the list.
    For this I use the DataObject and submit a query. But as I want to do this in the OnLoadEvent, I can't use forceupdate() to populate the dropdown list.
    How do I get the result from the sql select into the dropdown list?

    Thanks in advance.

    Regards,

    Buki
  • 08-21-2006 12:12 PM In reply to

    Re: populate dropdown during OnLoadEvent

    Hi Buki,
    Aren't you binding your dropdown do the "DataObject" that you are querying?
    When you do that then it gets automatically updated in the dropdown. You dont need to call forceupdate().
  • 08-22-2006 01:06 AM In reply to

    Re: populate dropdown during OnLoadEvent

    Hi,

    maybe I get something wrong, but when I look at this secondary data source it is a repeating element. The dropdown list is not a repeating element, so I can't bind the dropdown list to the secondary data source.
    When I bind the list entries of the dropdown (properties dialog) to the datasource, only an empty row and the first entry is shown when I open the form. Furthermore when I select the empty row the other empty disappears?
    What am I missing?

    Regards,

    Buki
  • 08-22-2006 04:24 PM In reply to

    Re: populate dropdown during OnLoadEvent

    You don't bind the drop-down itself to the repeating element, you right-click your drop-down and choose Properties, and then set it up to be populated from that repeating list.
  • 08-29-2006 12:05 AM In reply to

    Re: populate dropdown during OnLoadEvent

    Ok. I understand. But how does the drop down know what value to display, when I use managed code to populate the dropdown.
    For example, I bind a secondary datasource to the dropdown by the datasource wizard. I add an access database and if I look at the created sql it looks like
    select [id],[course_name] from [courses] as [courses]

    But now I want to use a more complex sql statement within my C# code.
    "select c.course_name,c.id "
    +"from courses c, "
    +" (select count(id) as part, courseID as cID from course_participants group by courseID) d "
    +"where c.participants > d.part "
    +" and c.id = d.cID "
    +"group by c.course_name, c.id"
    How does the dropdown know to be updated correctly? Or how does the sql have to look like in order to work? Do the columns have to be named the same way? And what do I do if I want to populate the dropdown by concatenating the retrieved values, e.g. course name and course id?

  • 08-30-2006 03:13 AM In reply to

    Re: populate dropdown during OnLoadEvent

    Ok. I figured it out. I create a view in the database with the desired fields and select this view when I create a secondary datasource. So I can bind the e. g. concatenated fields to a field in the primary datasource.
    Thanks for hints!
  • 08-30-2006 01:16 PM In reply to

    Re: populate dropdown during OnLoadEvent

    So glad you got it working! Glad to have helped!

    Keep up the good work!
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.