macupryk Posted September 27, 2003 Posted September 27, 2003 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)); } } } Quote
aewarnick Posted September 28, 2003 Posted September 28, 2003 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. Quote C#
macupryk Posted September 28, 2003 Author Posted September 28, 2003 Can u give me a more descriptive example please. Quote
aewarnick Posted September 28, 2003 Posted September 28, 2003 //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. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.