Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am repopulating the checkboxlist on postback.

Can someone help me with the syntax?

 

private void FillcblMusic(DataView data)

{

ArrayList selItems = (ArrayList)Session["webform6_cblMusic"];

//iterate over the Items to see which are selected

foreach (ArrayList selItems in this.selItems.LastIndexOf(selItems))

{

if (item.Value == (ArrayList)Session ["webform6_cblMusic"].ToString())

{

selItems.Add(this.cblMusic.Items.IndexOf(item));

}

 

}

 

}

Posted

foreach (ArrayList selItems in this.selItems.LastIndexOf(selItems))

 

I think your problem is right there. You iterate through the type of items in the Arraylist. You are trying to iterate through any items in the ArrayList that are of type ArrayList.

 

For example, if the items stored in the ArrayList of strings then you would write

foreach(string x in this.selItems)

 

if you don't know the type just use object instead.

C#
Posted

//up right underneath the Form class, making it a global variable accessable all throughout the class.
ArrayList selItems=new ArrayList();

//down in your code somewhere
foreach(string x in this.selItems)
{
 if(x==item.Value)
   this.selItems.Add(x);
}

If that is not good enouph, post what you are doing and I'll try to put that together for you.

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...