I want to use the same sqlDataSource for two CheckBoxList controls in ASP.NET
2.0.
For simplicity, I am using the case of only two CheckBoxList controls in the
following example:
My sqlDataSource is bound to a table in my database. The table has four
columns, say, col1_ID, col1_value and col2_ID, col2_value.
The DataValueField and DataTextField values for CheckBoxList1 are bound to
col1_ID and col1_value respectively. And, for CheckBoxList2, the
DataValueField and DataTextField values are bound to col2_ID, col2_value
columns respectively.
Suppose the data in myTable looks as follows:
Col1_ID Col1_value Col2_ID Col2_value
1 Value11 1 Value21
2 Value12 2 Value22
3 Value13 NULL NULL
When I run my code, the CheckBoxList1 displays the three check boxes, as
expected, with their corresponding values (value11, value12 and value13).
BUT, CheckBoxList2 also display the three check boxes with third check box
having no value.
I do not want a check box to be diplayed if the column has a NULL value. How
can I accomplish this by using only one sqlDataSource?
Since I will be using lots of CheckBoxList controls, I do not want to use
lots of sqlDataSource controls for each CheckBoxList for performance reasons.
Moreover, I want to use only one table with the different pairs of
col_ID,col_value columns in the same table.
Nam