On Thu, 02 Nov 2006 10:39:48 +0100, Øyvind Isaksen <ho***@egmont.n owrote:
Got it:
//Make sting-Array:
string[] arrInterest = new string[1000];
for (int i = 0; i < chkInterests.It ems.Count; i++)
{
if (chkInterests.I tems[i].Selected)
{
arrInterest[i] = (string)chkInte rests.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.It ems.Count];
But even this will create empty spaces. To create a size of only selected
items use a List<Tand possibly its ToArray
List<stringsele ction = new List<string>();
foreach (ListItem li in CheckBoxList1.I tems)
{
if (li.Selected)
selection.Add(l i.Text);
}
Swap List with ArrayList if you are using framework 1.1
--
Happy Coding!
Morten Wennevik [C# MVP]