views:

696

answers:

2

Hi,

I'm working on an InfoPath 2007 form. I have two drop-down lists and i need the second to be populated with items bases on the value chosen in the first list. I use c# to populate the drop-dpwn lists from external sources. I've tried to use the OnChange event to make all this, but the second list is still empty.

If anyone knows, please tell me.

+2  A: 

You can filter the entries for the second drop-down list based on your first list (but only if the entries are based on a data source, not manually entered).

  1. Bring up the properties window for your second drop-down list.
  2. Select your data source.
  3. Click on the button to the right of the Entries text box.
  4. Select the repeating node you wish to use for the basis of your list entry.
  5. Click the Filter Data button. From here you can enter a filter to limit the entries displayed based on the value of your first drop-down list.

Your question was a bit ambiguous. You may be trying to populate a secondary data source based off of your first drop-down list. This should work fine with an OnChange event. Can you post the code you are using to do this?
Some additional tips that may help:

  • The change event will not fire until focus moves off of the list box. So, for the second drop down to populate, you will need to set the first drop-down then hit tab or click elsewhere in the form.
  • I don't know the size or nature of the data source you are using for the second drop-down list, but you may consider downloading the entire data source and filter it using the method I described above. This may be a better solution as you won't need to make a database query between entering the first list box and the second one.
oillio
A: 

I was on the right way, but i should have done one more thing. The Change() event was actually fired, but the changes were not seen because the postback was disabled on that field. So, i enabled the postback (selected "always" postback) and now it works fine. Thank you, though, for your answers.

Alexandr

related questions