On Thu, 02 Nov 2006 10:39:48 +0100, Øyvind Isaksen <ho***@egmont.nowrote:
Got it:
//Make sting-Array:
string[] arrInterest = new string[1000];
for (int i = 0; i < chkInterests.Items.Count; i++)
{
if (chkInterests.Items[i].Selected)
{
arrInterest[i] = (string)chkInterests.Items[i].Text;
}
}
This will create an unecessary long list with plenty of empty lines.
To limit the size to no more than the size of the CheckBoxList use
string[] arrInterest = new string[chkInterests.Items.Count];
But even this will create empty spaces. To create a size of only selected
items use a List<Tand possibly its ToArray
List<stringselection = new List<string>();
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
selection.Add(li.Text);
}
Swap List with ArrayList if you are using framework 1.1
--
Happy Coding!
Morten Wennevik [C# MVP]