Programmatically change the Item in Drop Dow List box

  • Thread starter Paramasivan Sakthivadivel
  • Start date
P

Paramasivan Sakthivadivel

Hi gys,

I need to set particular Item as a selected Item in Drop down list box
through code behind file in InfoPath. Its any help me regarding this..

Advance Thanks

By

Param
 
G

Greg Collins

The drop-down list box control is bound to a particular XML node. Change the
value of that XML node and your drop-down will automatically update it's
selection.
 
P

Param

Thanks for response Greg Collins,

I try to change the text of the particular element in code behind file but
its not shows any changes in the infopath view. Here i have mention my
scenario

In my project i had two drop down list(DDL) 1) Category 2) States.
the value filled from XML file for both DDL box for this i had two
different methods in my code behind file to bound the value to DDL.

Here my job is to set the particular item for an example "General" as
Category and "US " as States this is default value i want to set in both DDL

I try to set default item by using text property after completion of bound
but its not working.
 
G

Greg Collins

A drop-down list has two values: the value that is stored, and the value
that is displayed.

For example, it might have value="1" display="US"

When you set the value of the DOM node via code, you need to use the stored
value, and not the displayed value. If you set the node value to "1" the
drop-down will display "US". If you set it to "US", it will display "US",
but it will a) have the wrong stored value, and b) show two instances of
"US" in the drop-down... one instance is associated with the value "1", and
the other is the same as: value="US" display="US"... these two instances are
not the same.

If you are seeing absolutely no changes when setting the node value via
code, then it is likely your code is referencing the wrong XPath to that DOM
node.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top