473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Checkbox arrays

I have an app that requires the use of a 2 dimensional array of
checkboxes. I can't seem to assign any values to them. I tried this:

Dim BonusChecks(0, 0) As CheckBox

...and then later when I know the domensions I'll need:

ReDim BonusChecks(x,y) ' (3,3), no error
BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of
an object

If it's not allocated any memory, what did the redim statement do?

So I found another syntax:

Dim BonusChecks(3,3) as New Checkbox ' No error
BonusChecks(0,0).ID = "1" ' Same error,

What am I missing? I thought ReDim or New would initialize the array.
How do I get an array of checkboxes working?

Thanks!

Mar 14 '06 #1
6 1602
AFAIK,

ReDim only changes the size of the array, don't you need to add an
instance of type checkbox to (0,0)?

I might be way off base here, never touched checkbox arrays b4

Mar 14 '06 #2
..net does not have control arrays like vb6.

Dim BonusChecks(3,3) as New Checkbox

creates a 2 dimensional array of type Checkbox. all the entries will be null
(nothing in vb), until you put an entry in the array. a redim, keeps the old
values, but the new values will be null.

also unlike vb6 control arrays, adding control to an array will not make
them appear. you need to add then to the page. the most common approach is
to add a place holder to the page, and add the controls to the placeholder.
also if you create dynamic control, you must recreate them on postback
(before onload), so be sure to save some state infomation in viewstate, to
know what to do.

you would proably be better off using a repeater with templates.
-- bruce (sqlwork.com)

"Fred Flintstone" <id**********@nospam.com> wrote in message
news:5g********************************@4ax.com...
I have an app that requires the use of a 2 dimensional array of
checkboxes. I can't seem to assign any values to them. I tried this:

Dim BonusChecks(0, 0) As CheckBox

..and then later when I know the domensions I'll need:

ReDim BonusChecks(x,y) ' (3,3), no error
BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of
an object

If it's not allocated any memory, what did the redim statement do?

So I found another syntax:

Dim BonusChecks(3,3) as New Checkbox ' No error
BonusChecks(0,0).ID = "1" ' Same error,

What am I missing? I thought ReDim or New would initialize the array.
How do I get an array of checkboxes working?

Thanks!

Mar 14 '06 #3
".net does not have control arrays like vb6."

But I use single dimension arrays of dynamic textboxes that work just
fine.

">creates a 2 dimensional array of type Checkbox. all the entries will
be null (nothing in vb), until you put an entry in the array."

Isn't that what this is doing?:

Dim BonusChecks(3,3) as New Checkbox ' No error
BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of

Thanks for the reply, much appreciated.

On Tue, 14 Mar 2006 09:09:49 -0800, "Bruce Barker"
<br******************@safeco.com> wrote:
.net does not have control arrays like vb6.

Dim BonusChecks(3,3) as New Checkbox

creates a 2 dimensional array of type Checkbox. all the entries will be null
(nothing in vb), until you put an entry in the array. a redim, keeps the old
values, but the new values will be null.

also unlike vb6 control arrays, adding control to an array will not make
them appear. you need to add then to the page. the most common approach is
to add a place holder to the page, and add the controls to the placeholder.
also if you create dynamic control, you must recreate them on postback
(before onload), so be sure to save some state infomation in viewstate, to
know what to do.

you would proably be better off using a repeater with templates.
-- bruce (sqlwork.com)

"Fred Flintstone" <id**********@nospam.com> wrote in message
news:5g********************************@4ax.com.. .
I have an app that requires the use of a 2 dimensional array of
checkboxes. I can't seem to assign any values to them. I tried this:

Dim BonusChecks(0, 0) As CheckBox

..and then later when I know the domensions I'll need:

ReDim BonusChecks(x,y) ' (3,3), no error
BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of
an object

If it's not allocated any memory, what did the redim statement do?

So I found another syntax:

Dim BonusChecks(3,3) as New Checkbox ' No error
BonusChecks(0,0).ID = "1" ' Same error,

What am I missing? I thought ReDim or New would initialize the array.
How do I get an array of checkboxes working?

Thanks!


Mar 14 '06 #4
On 14 Mar 2006 09:09:03 -0800, "dkode" <dk****@gmail.com> wrote:
AFAIK,

ReDim only changes the size of the array, don't you need to add an
instance of type checkbox to (0,0)?

I might be way off base here, never touched checkbox arrays b4

"don't you need to add an instance of type checkbox to (0,0)?"

Isn't that what this is doing?:

Dim BonusChecks(3,3) as Checkbox
BonusChecks(0,0).ID = "1"

Doesn't the Dim statement allocate memory for the entire array? (16
elements)

It's like this is some kind of new array type that defies the basic
behavior of an array. I'm completely confused by it.

Thanks!

Mar 14 '06 #5
Wait, I got it:

Dim BonusChecks(3,3) as Checkbox

Bonuschecks(0,0) = New Checkbox
BonusChecks(0,0).ID = "1"

THAT works. Thanks for the push. :)

On Tue, 14 Mar 2006 09:09:49 -0800, "Bruce Barker"
<br******************@safeco.com> wrote:
.net does not have control arrays like vb6.

Dim BonusChecks(3,3) as New Checkbox

creates a 2 dimensional array of type Checkbox. all the entries will be null
(nothing in vb), until you put an entry in the array. a redim, keeps the old
values, but the new values will be null.

also unlike vb6 control arrays, adding control to an array will not make
them appear. you need to add then to the page. the most common approach is
to add a place holder to the page, and add the controls to the placeholder.
also if you create dynamic control, you must recreate them on postback
(before onload), so be sure to save some state infomation in viewstate, to
know what to do.

you would proably be better off using a repeater with templates.
-- bruce (sqlwork.com)

"Fred Flintstone" <id**********@nospam.com> wrote in message
news:5g********************************@4ax.com.. .
I have an app that requires the use of a 2 dimensional array of
checkboxes. I can't seem to assign any values to them. I tried this:

Dim BonusChecks(0, 0) As CheckBox

..and then later when I know the domensions I'll need:

ReDim BonusChecks(x,y) ' (3,3), no error
BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of
an object

If it's not allocated any memory, what did the redim statement do?

So I found another syntax:

Dim BonusChecks(3,3) as New Checkbox ' No error
BonusChecks(0,0).ID = "1" ' Same error,

What am I missing? I thought ReDim or New would initialize the array.
How do I get an array of checkboxes working?

Thanks!


Mar 14 '06 #6
i knew it was something along those lines :)

Mar 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Old Lady | last post by:
Hi all, I have a problem when I try to send an array using a form when the type="checkbox". This is my form input row: <INPUT type="Checkbox" name="flg" value="y" <? if($row == 'y') echo...
4
by: Bill | last post by:
I have a catalog of books which need to be categorized into different groups. Some of the books can be listed under more than one category. I'm creating a page where I can assign a group of books...
4
by: Piotr | last post by:
how can I read (in alert for example) array index number of checked checkbox? I have: <input type="checkbox" id="id_number" name="check" value="1" onclick="show()"/> <input type="checkbox"...
8
by: Jeremy | last post by:
If we have a table with say 3 rows in it and one of the columns contains a checkbox such as <table> <tr> <td><input type="checkbox" name="ch_fld"></td> </tr> <tr> <td><input type="checkbox"...
1
by: newbie | last post by:
Hello All, I'm trying to figure out this array problem I have. I don't know if I'm doing this correctly. Anyone want to take a look. --------------------- Current Situation....
2
by: newbie | last post by:
Hello All, I'm trying to figure out this array problem I have. I don't know if I'm doing this correctly. Anyone want to take a look. --------------------- Current Situation....
2
by: dkultasev | last post by:
Hello, I have small script which generates some listboxes. Their names are listXX (list01, list02, list03....). How to check if there are checked or not ? If I have 1 listbox and have it's name I...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
0
by: msg4james | last post by:
G'day folks, I have an intriguing question, one which most programmers have been talking around, and the solutions I have seen posted often inadequate: <INPUT TYPE=CHECKBOX NAME="Profession" ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.