开发者

How to fill up a list based on another list's value in InfoPath

开发者 https://www.devze.com 2023-03-12 03:19 出处:网络
I have a list which holds country values. This list is shown in a drop down. I have another drop down for states. When I select the country, the state drop down should be populated with the states of

I have a list which holds country values. This list is shown in a drop down. I have another drop down for states. When I select the country, the state drop down should be populated with the states of the selected country. I am new to InfoPath and I don't know how to achieve this.

In C# I would write something like this (please ignore syntax):

if(state.country == countryDropDown.SelectedValue)
StateDropDown.add(State开发者_运维百科);

How can I do the same in InfoPath?


In the state drop down list, add a filter so that you only show the states belonging to the country. Here is a link showing you how http://koobarspoint.blogspot.com/2010/06/cascading-drop-downs-with-infopath-2010.html (no code behind is required)


if your data is in sharepoint list then you can use CAML query to fetch the data You need to create repeating field and bind that repeating field to staet dropdown. To fetch the state based on country selected is -

string strCountry=this.maindatasource.createnavigator().selectsinglenode("xpath of country dropdown",namespacemanager).value;

SPList oList = web.Lists["Name of List"];
SPQuery oQuery = new SPQuery();

oQuery.Query = "<Where><Eq><FieldRef Name='column name which contains countries' /><Value Type='Text'>" + strCountry + "</Value></Eq></Where>";

SPListItemCollection oListItemCollection = oList.GetItems(oQuery);

foreach (SPListItem Item in oListItemCollection)
{                                           
   root.SelectSingleNode("xpath of field inside repeating table",NamespaceManager).SetValue(Item["Name of column which holds state"].ToString());

}
0

精彩评论

暂无评论...
验证码 换一张
取 消