Thanks for the suggestions...
I've tried adding a custom attribute to the ListItems by iterating through
all the ListItems after the CheckBoxList has been databound and adding a new
custom attribute that holds the DataValueField value for each ListItem.
However, looking at the html when the CheckBoxList is rendered, the
individual html checkbox input controls that the CheckBoxList becomes do not
have the custom attribute I added. Perhaps I am doing something wrong or
adding the custom attributes at the wrong time...I'm adding them in Page_Load
when it is not a postback, that is, the first time the page is accessed.
As for the hidden input controls approach, I'm not entirely sure how I would
link the hidden controls to the individual html checkboxes that are
rendered...I can dynamically add a bunch of hidden controls which hold the
DataValueField values for each ListItem...but how do I tell which hidden
input control refers to which html checkbox control? I guess one way around
this would be to try to add a custom attribute to the hidden controls to hold
the id of the checkbox that each one refers to.
I guess my problem is that when the CheckBoxList is rendered into individual
html checkbox inputs, those checkbox inputs only have id, name and checked
attributes on client-side and lose their mapping to the data the CheckBoxList
was bound to.
I'm trying to get the DataValueField on client-side because I'm trying to
implement a client-side validation function on the CheckBoxList items...so
when a user checks a particular CheckBoxList item, the validation should
check that a bunch of other controls are completed. The server-side
validation for this is working fine so maybe I'll just leave it as a
server-side only validator.
Cheers again, Dune