473,396 Members | 1,849 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 Question 2

I use the following way to generate a table with a checkbox each row:

TableRow rowA;
for (int i = 1; i<=10 ; i++)
{
rowA = new TableRow();
cellA = new TableCell();
CheckBox CB = new CheckBox();
cellA.Controls.Add(CB);
row.Cells.Add(cellA);
rowA.Cells.Add(cellA);
}

How can I give those 10 checkboxs different value & how can I obtain them?

Jul 7 '08 #1
3 1092
you should give each checkbox a unique ID. then be sure to recreate the
checkboxs (with the name id's) on postback in the CreateChildControls
method. you also need to add the rows to the table.

-- bruce (sqlwork.com)

Elliot wrote:
I use the following way to generate a table with a checkbox each row:

TableRow rowA;
for (int i = 1; i<=10 ; i++)
{
rowA = new TableRow();
cellA = new TableCell();
CheckBox CB = new CheckBox();
cellA.Controls.Add(CB);
row.Cells.Add(cellA);
rowA.Cells.Add(cellA);
}

How can I give those 10 checkboxs different value & how can I obtain them?
Jul 8 '08 #2
I see.
Thanks, Bruce.
"bruce barker" <no****@nospam.comwrote in message
news:uv*************@TK2MSFTNGP02.phx.gbl...
you should give each checkbox a unique ID. then be sure to recreate the
checkboxs (with the name id's) on postback in the CreateChildControls
method. you also need to add the rows to the table.

-- bruce (sqlwork.com)

Elliot wrote:
>I use the following way to generate a table with a checkbox each row:

TableRow rowA;
for (int i = 1; i<=10 ; i++)
{
rowA = new TableRow();
cellA = new TableCell();
CheckBox CB = new CheckBox();
cellA.Controls.Add(CB);
row.Cells.Add(cellA);
rowA.Cells.Add(cellA);
}

How can I give those 10 checkboxs different value & how can I obtain
them?
Jul 8 '08 #3
On 7 Jul, 23:56, "Elliot" <elliot_barc...@hotmail.co.ukwrote:
I use the following way to generate a table with a checkbox each row:

* * * * * * TableRow rowA;
* * * * * * for (int i = 1; i<=10 ; i++)
* * * * * * {
* * * * * * * * rowA = new TableRow();
* * * * * * * * cellA = new TableCell();
* * * * * * * * CheckBox CB = new CheckBox();
* * * * * * * * cellA.Controls.Add(CB);
* * * * * * * * row.Cells.Add(cellA);
* * * * * * * * rowA.Cells.Add(cellA);
* * * * * * }

How can I give those 10 checkboxs different value & how can I obtain them?
You need to run the TableRow construction routine during the Page_Load
event every time (both on the initial page request and during post
back). Thereafter the CheckBox states will be available via the Table
object (presumably declared in page source or globally within the
webform class definition) in any event handler for postback. By
default ViewState is enabled for WebControls and the matching of
CheckBoxes in ViewState with those re-created during Page_load will
occur automatically (ASP.NET uses automatically generated the clientID
for this).

Try it and see

Good luck
Jul 8 '08 #4

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

Similar topics

4
by: Fabri | last post by:
How can I, on button click, to select ONLY the following 4 checkbox? I would like to do this without a for loop through form.lenght because this is only an example and I have to apply this script...
4
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
2
by: bebop | last post by:
I'm using three checkbox web controls in C# .NET and one button, and one labe Is there a way to "group" these individual checkbox web controls If so, do I use a for loop, hashtable, array,...
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
2
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to...
2
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox...
4
by: Wolfgang Uhr | last post by:
Hello I've the following code Panel pnlData = new System.Windows.Forms.Panel(); CheckBox checkBox = new System.Windows.Forms.CheckBox(); checkBox.AutoSize = true; checkBox.Dock =...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.