ASP.Net Checkbox Problem

  • Thread starter Thread starter mschmidt18
  • Start date Start date
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
 
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
 
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
}
 
Back
Top