checkboxes with array list...................... [Resolved]

Posted by Samanthajyesta under ASP.NET on 6/17/2010 | Views : 1973 | Status : [Member] | Replies : 9
hi,
i've 5 check boxes in my application. when i click the button after selecting the checkboxes, those selected checkboxes should be saved in arraylist.
how can we store those in an array list.

http://www.dotnetfunda.com


Responses

Posted by: Samanthajyesta on: 6/23/2010 [Member] Starter

Up
0
Down

Resolved
i got the solution sir,that i've declared my arraylist object ,outside the scope.
then my count got incremented.

http://www.dotnetfunda.com

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/17/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i am not infront of my dev computer but you would do something like

ArrayList Arrlist = new ArrayList();
for (int i; i <= cbList.Items.Count - 1; i++)
{

if (cbList.Items[i].Selected)
{
//Add to Arrlist
Arrlist.Add(cbList.Items[i]);
}

}


Arraylist are old , look at
List<String>


Thank you for posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samanthajyesta on: 6/17/2010 [Member] Starter

Up
0
Down
hi sir,i tried the code that u sent. in forloop the count of Arraylist is gettin incremented.
How can we increment the count of Arrlist.

http://www.dotnetfunda.com

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/17/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
This Will do


Arrlist++


Thank you for posting at Dotnetfunda
[Administrator]

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samanthajyesta on: 6/17/2010 [Member] Starter

Up
0
Down
hi sir, i already tried. but it is showing an error message like.. cannot be applied to operand of type System.Collections.ArrayList.

http://www.dotnetfunda.com

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/17/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Try using it like this

Arrlist = Arrlist + 1 ;


Thank you for posting at Dotnetfunda
[Administrator]

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samanthajyesta on: 6/18/2010 [Member] Starter

Up
0
Down
hi sir, here the problem is the '++' not getting applied to the System.Collections.ArrayList.
then how can we increment the size of the array list.

http://www.dotnetfunda.com

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/18/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
So basically you want to increase the size of the Arraylist, then you need to remember that Arraylist came after the Array, they are not exactly like Arrays . if you use the Add method it automatically increases the size of the arraylist ,you dont need to increase it. that is why for unknown dimensions you will declare you arraylist without any max dimension.

Hope this helps , tell me if you don't understand.

Thank you for posting at Dotnetfunda
[Administrator]

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/23/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i am glad you sorted it out. mark your answer as Answered.

Thank you again for posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Samanthajyesta, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response