I have a Multiple-Selection List Box that uses an external data source to populate the check box items. This data source is an xml document that gets dynamically populated in the code behind in the On_Load method from a SharePoint list with the Title field and a Check box field. I have three items in this list and all three show up in the Multiple-Selection List Box. But when I check one of the check boxes, all three of them become checked, and vice-versa. I suspect this is because my Multiple-Selection List box is bound to a single repeating field.
\r\n
Any suggestions on how I can check just one item in this Multiple-Selection List Box and not have every other item get checked as well?
Edit: Here is the code from my code behind that populates the xml document that is used to back the Multiple Selection List Box
private void PopulateIndicators(SPWeb web)
{
string dataConnectionName = "IndicatorList";
RemoveFirstItem(dataConnectionName);
SPList reasonssList = web.Lists["CIAC Test List"];
string name = string.Empty;
string displayValue = string.Empty;
foreach (SPListItem item in reasonssList.Items)
{
if (item["Title"] != null && item["Indicator"] != null)
{
name = item["Indicator"].ToString();
displayValue = item["Title"].ToString();
}
AddItem(name, displayValue, dataConnectionName);
}
RemoveFirstItem(dataConnectionName);
}
private void RemoveFirstItem(string dataConnectionName)
{
XPathNavigator DOM = DataSources[dataConnectionName].CreateNavigator();
XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);
XPathNavigator field1 = DOM.SelectSingleNode("//options/option", NamespaceManager);
field1.DeleteSelf();
}
private void AddItem(string itemId, string itemName, string dataConnectionName)
{
XPathNavigator DOM = DataSources[dataConnectionName].CreateNavigator();
XPathNavigator group1 I have a Multiple-Selection List Box that uses an external data source to populate the check box items. This data source is an xml document that gets dynamically populated in the code behind in the On_Load method from a SharePoint list with the Title field and a Check box field. I have three items in this list and all three show up in the Multiple-Selection List Box. But when I check one of the check boxes, all three of them become checked, and vice-versa. I suspect this is because my Multiple-Selection List box is bound to a single repeating field.
\r\n
Any suggestions on how I can check just one item in this Multiple-Selection List Box and not have every other item get checked as well?
Edit: Here is the code from my code behind that populates the xml document that is used to back the Multiple Selection List Box
private void PopulateIndicators(SPWeb web)
{
string dataConnectionName = "IndicatorList";
RemoveFirstItem(dataConnectionName);
SPList reasonssList = web.Lists["CIAC Test List"];
string name = string.Empty;
string displayValue = string.Empty;
foreach (SPListItem item in reasonssList.Items)
{
if (item["Title"] != null && item["Indicator"] != null)
{
name = item["Indicator"].ToString();
displayValue = item["Title"].ToString();
}
AddItem(name, displayValue, dataConnectionName);
}
RemoveFirstItem(dataConnectionName);
}
private void RemoveFirstItem(string dataConnectionName)
{
XPathNavigator DOM = DataSources[dataConnectionName].CreateNavigator();
XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);
XPathNavigator field1 = DOM.SelectSingleNode("//options/option", NamespaceManager);
field1.DeleteSelf();
}
private void AddItem(string itemId, string itemName, string dataConnectionName)
{
XPathNavigator DOM = DataSources[dataConnectionName].CreateNavigator();
XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);
XPathNavigator field1 = DOM.SelectSingleNode("//options/option", NamespaceManager);
XPathNavigator newNode = field1.Clone();
newNode.SelectSingleNode("value").SetValue(itemId);
newNode.SelectSingleNode("displayname").SetValue(itemName);
group1.AppendChild(newNode);
}