如何根据 InfoPath 中另一个列表的值填充列表

发布于 2024-11-14 14:52:30 字数 290 浏览 9 评论 0原文

我有一个包含国家/地区价值观的列表。该列表显示在下拉列表中。我还有另一个针对各州的下拉列表。当我选择国家/地区时,州下拉列表中应填充所选国家/地区的州。我是 InfoPath 的新手,我不知道如何实现这一点。

在 C# 中,我会写这样的内容(请忽略语法):

if(state.country == countryDropDown.SelectedValue)
StateDropDown.add(State);

How can I do the same in InfoPath?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

慈悲佛祖 2024-11-21 14:52:30

在州下拉列表中,添加过滤器,以便仅显示属于该国家/地区的州。这是一个链接,向您展示如何 http:// koobarspoint.blogspot.com/2010/06/cascading-drop-downs-with-infopath-2010.html(不需要后面的代码)

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)

疯了 2024-11-21 14:52:30

如果您的数据在共享点列表中,那么您可以使用 CAML 查询来获取数据
您需要创建重复字段并将该重复字段绑定到 staet 下拉列表。
要根据所选国家/地区获取州/省/地区是 -

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());

}

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());

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文