T
Trond
I have a CheckBoxList on my ASP.NET page. It is populated from a dataset:
DataSet dsType = new DataSet();
dsType = rmController.GetStatusMessages();
CheckBoxList1.DataSource = dsType.Tables[0];
CheckBoxList1.DataTextField =
dsType.Tables[0].Columns["Status"].ColumnName.ToString();
CheckBoxList1.DataValueField=
dsType.Tables[0].Columns["IDStatus"].ColumnName.ToString();
CheckBoxList1.DataBind();
----------------------------------------------------------
So far so good
Then the user can select 1 or more options in CheckBoxList1 that in this
case counts 4 items. IDStatus is an integer and Status is the text:
1 option1
2 option2
4 option3
8 option4
SO if the user selects option2 and option4 i want to be able to return 2 + 8
(10).
I tried to fig out how i can test if an item is checked or not. It is easy
in a winform but the ASP.NET control is not that easy
Here is code that i have been playing with:
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items.???==true)
{
checksum += int.Parse(CheckBoxList1.Items.Value);
}
}
Any hint that can help me out is appreciated.
Best regards Trond
DataSet dsType = new DataSet();
dsType = rmController.GetStatusMessages();
CheckBoxList1.DataSource = dsType.Tables[0];
CheckBoxList1.DataTextField =
dsType.Tables[0].Columns["Status"].ColumnName.ToString();
CheckBoxList1.DataValueField=
dsType.Tables[0].Columns["IDStatus"].ColumnName.ToString();
CheckBoxList1.DataBind();
----------------------------------------------------------
So far so good
Then the user can select 1 or more options in CheckBoxList1 that in this
case counts 4 items. IDStatus is an integer and Status is the text:
1 option1
2 option2
4 option3
8 option4
SO if the user selects option2 and option4 i want to be able to return 2 + 8
(10).
I tried to fig out how i can test if an item is checked or not. It is easy
in a winform but the ASP.NET control is not that easy
Here is code that i have been playing with:
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items.???==true)
{
checksum += int.Parse(CheckBoxList1.Items.Value);
}
}
Any hint that can help me out is appreciated.
Best regards Trond