RE: Customised Web Application for Microsoft CRM Online
I've programmed a checklistbox control in ASP.NET (C#) Web Form that displays a number of items from Microsoft CRM Online via LINQ.
List<string> selDropdown = chkMyItemsHere.Items.Cast<ListItem>()
.Where(li => li.Selected)
.Select(li => li.Value)
.ToList();
string ListBoxValues = string.Join(", ", selDropdown);
This works perfectly and I'm able to save the string into one field (i.e. 'string value, string value').
Now, on Page_Load I need to split the values from the combined string and tick the relevant checkboxes in the checkListbox.
string[] k = i.LINQFIELD.Split(',');
for (int m = 0; m <= k.Length - 1; m++)
{
for (int x = 0; x <= chkMyItemsHere.Items.Count; x++)
{
if (chkMyItemsHere.Items[x].Value == k[m])
{
chkMyItemsHere.Items[x].Selected = true;
}
}
}
Any ideas why this wouldn't be re-populating my checkboxlist? Any help would be greatly appreciated.
In your code that works, you have this:
In your code that does not, you have this:
Do you see it?
As a solution, I propose you declare a constant variable like so:
Now you have this:
and