problems with CheckBoxList

P

Philip Townsend

I am having some difficulty getting a checkboxlist control to determine
which checkboxes are checked. Here is a code sample from the event that
should read it:

private void btnFilter_Click(object sender, System.EventArgs e)
{
ArrayList arr=new ArrayList();
for(int i=0;i<ckFilter.Items.Count;i++)
{
if(ckFilter.Items.Selected)
{
arr.Add(ckFilter.Items.Text);
}
}
IEnumerator en=arr.GetEnumerator();
while(en.MoveNext())
{
Response.Write(en.Current+"<br>");
}
}


The only problem is that ckFilter.Items.Selected always returns false
regardless of whether the box is checked. I am sure this is a simple
problemAny ideas?
 
M

Michael Ramey

The code looks fine to me, how are you binding data to this checkboxlist?
Are you making sure not to rebind this data on postbacks?

--Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top