Hello Greg,
Can you please help to get my cascading dropdown list to work properly in a repeating table? My lists seem to work fine until I add another row to the table and the first row gets kinda squirrelly. The following is a snippet of the code. What would I have to do to get the addittional rows to work properly. I'm think that i'll have to check for the last node in the repeating group and then do something. I don't know what to do really. Can you help? Thanks.
private void PopulateCascadingDropDown(string selectedMainValue,
string dataConnectionName, string dataSourceName, string
repeatingNode,
string ForeignKey, string
CascadingDropDownDataSourceField)
{
//-- Set the Value of the Cascading Dropdown in the Main
//-- Data Source to empty --
//-- This is needed, the previous selected node will stay
//-- in the list --XPathNavigator xnMain = this.MainDataSource.CreateNavigator();
xnMain.SelectSingleNode(CascadingDropDownDataSourceField,
this.NamespaceManager).SetValue(string.Empty);
//-- Execute the DataConnection --DataConnection dcSecond = this.DataConnections[dataConnectionName];
dcSecond.Execute();
//-- Get a Navigator to the Secondary DataSource, just created by
//-- previous line of code --XPathNavigator xnFD = this.DataSources[dataSourceName].CreateNavigator();
//-- Create xPathString: Select all nodes where the foreignkey is
//-- different from the selected Value --string xPathString = repeatingNode + "[@" + ForeignKey + "!='" +
selectedMainValue +
"']";
//-- Get the nodes, corresponding the xPathString --XPathNodeIterator items = xnFD.Select(xPathString,
this.NamespaceManager);while (items.Count != 0)
{
xnFD.SelectSingleNode(xPathString,
this.NamespaceManager).DeleteSelf();items = xnFD.Select(xPathString, this.NamespaceManager);
}
}
public void CTRL30_5_Clicked(object sender, ClickedEventArgs e)
{
const string f1 = "/my:myFields/my:group1/my:group2"; //repeating group name
XPathNavigator root = e.Source; //assign to root navigator
XPathNodeIterator rows = root.Select(f1, NamespaceManager); //use select to iterate
string id = rows.Current.SelectSingleNode("/my:myFields/my:field1", NamespaceManager).Value; //this returns value of the current row
//XPathNavigator root = MainDataSource.CreateNavigator();string dataConnectionName = "testDetail";
string dataSourceName = "testDetail";string ForeignKey = "masterid";
string CascadingDropDownDataSourceField = "/my:myFields/my:group1/my:group2/my:field2";
//string selectedMainValue = root.SelectSingleNode("/my:myFields/my:field1", NamespaceManager).Value;string selectedMainValue = id;string repeatingNode = "/dfs:myFields/dfs:dataFields/d:testDetail";
PopulateCascadingDropDown(selectedMainValue, dataConnectionName,
dataSourceName, repeatingNode, ForeignKey, CascadingDropDownDataSourceField);
}