Last post Sep 10, 2009 07:17 AM by mamtagupta
Sep 09, 2009 06:47 AM|tdinpsp|LINK
I thought that the CheckBoxList databinding would be simlar to DropDownList databinding, and the first part is but I'm not sure where to begin for the "real" databinding.
The items in the CheckBoxList are easily populated from a SqlDataSource, so I have Text for CheckBox1 = "CheckBox1" Value for CheckBox1 = 1, Text for CheckBox2 = "CheckBox2" Value for CheckBox2 = 2 and so on. That of course does not set the Checked state
for any of the CheckBoxes. Asuming that the CheckBoxList is within a FormView and I have a SqlDataSource available that contains two columns, one is a bit which contains the Checked state and the other is a Value which corresponds to the Value from the first
SqlDataSource that was used to populate the list - how do I tell the CheckBoxList to get the Checked state from the second SqlDataSource.
Better yet what if the second data source is not the data source for the FormView that the CheckBoxList is within.
Sep 09, 2009 10:24 AM|mamtagupta|LINK
You have any sql table to bind data with checkboxlist.
Just bind it like dropdown.
CheckBoxList1.DataTextField="Name";//table field which you want to show
Sep 09, 2009 09:41 PM|tdinpsp|LINK
Yes, I know. That gets me the items in the list as I said in my post. What that does not get me is whether a particular item in the list is checked or not.
Sep 10, 2009 07:17 AM|mamtagupta|LINK
If you want to get checked items try this code
taxes = taxes + item.Value + ",";