Hi,
You have two drop downs, one for customer and one for address of selected customers. For dislpaying the address of selected customer from first dropdown follow these steps
* create secondary data source for retrive data. (name it Customer) this will fetch customer info from SP list. while creating this secondary data source keep the checkbox ON for retriving the data on load.
* create another secondary data source for retriving data. (name it Address) this will fetch customer address info from the SP list. while creating this data source keep the checkbox OFF for retriving the data on load
* copy the following code
public
void Customer_Changed(
object sender,
XmlEventArgs e)
{
XPathNavigator cities = MainDataSource.CreateNavigator();
cities.SelectSingleNode("/my:myFields/my:Address", NamespaceManager).SetValue("");
SetAddressOptions();
}
private void SetAddressOptions()
{
FileQueryConnection q = (FileQueryConnection)this.DataConnections["Address"];
q.FileLocation = q.FileLocation + "&FilterField1=Custcode&FilterValue1=" + GetAddressValue();
q.Execute();
}
private string GetAddressValue()
{
XPathNavigator nav = this.CreateNavigator();
string filtervalue = nav.SelectSingleNode("/my:myFields/my:Customer", this.NamespaceManager).Value;
return filtervalue;
}
This is working fine for me for my web based infopath form running in SP environment.
Hope will work for you as well
Enjoyyyyyyy
Bhavesh