ASP.Net Checkbox Problem

M

mschmidt18

Hello,

I am fairly familiar with Web Development with .Net, but i have come
across a problem that is giving me some trouble......

I want to have a list of checkboxes where 1) the labels come from one
table and 2) each box is checked or unchecked according to a different
table.

I have figured out a way to load the checkboxes by using a DataList. I
then put a single Checkbox in the ItemTemplate and bound the text and
checked properties.

My problem is that im not sure how to go about updating the table that
holds the Checked values. I dont know how to access each checkbox in
the DataList.

If someone has a better solution, i am completely open to
suggestions.....Please note i am developing in C#


Thanks,
Matt
 
T

Thomas Hansen

Hello,

I am fairly familiar with Web Development with .Net, but i have come
across a problem that is giving me some trouble......

I want to have a list of checkboxes where 1) the labels come from one
table and 2) each box is checked or unchecked according to a different
table.

I have figured out a way to load the checkboxes by using a DataList. I
then put a single Checkbox in the ItemTemplate and bound the text and
checked properties.

My problem is that im not sure how to go about updating the table that
holds the Checked values. I dont know how to access each checkbox in
the DataList.

If someone has a better solution, i am completely open to
suggestions.....Please note i am developing in C#

while( myDataReader.read() )
{
CheckBox x = new CheckBox();
x.Text = myDataReader["name"].ToString();
x.Checked = (bool)myDataReader["checked"];
Page.Controls.Add(x);
}



Then further up in your code populate your DataReader object according
to some inner join... e.g.:
"select * from x, y where x.someIdPreferableA_ForreignKey =
y.someOtherIdPreferableA_PrimaryKey"

....

..t
 
T

Teemu Keiski

Accessing the CheckBoxes in dataList can be accomplished with

foreach(DataListItem litem in DataList1.Items)
{
CheckBox cb = (CheckBox)litem.FindControl("CheckBox1");
//Process the CB here
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top