CheckBoxList not writting out values

Results 1 to 2 of 2

Thread: CheckBoxList not writting out values

  1. #1
    Join Date
    Dec 1969

    Default CheckBoxList not writting out values

    I have a dynamically created (non-bound) CheckBoxList on a Questionnaire Page. Each question can have a number of checkboxes ticked for it.<BR><BR>The questionnaire page itself posts off to another page that I don&#039;t have any control over. Trouble is this page is expecting the form results from the questionnaire page to be in name value pairs with the name of the question and then the option that was ticked.<BR><BR>Heres the crunch though, the checkboxes don&#039;t have a value property written for them when in a checkboxlist..!<BR><BR>I know there is a bug with the dropdown box not writting out its attributes correctly wondered if it is the same with the checkboxlist. Any ideas how to fix? Code below :<BR><BR>// Check boxes and their answers<BR>myCheckBoxList myList = new myCheckBoxList();<BR>myList.ID = text;<BR>this.Controls.Add( myList );<BR><BR>for ( int i=0; i&#060;answers.Count; i++ ) <BR>{<BR> ListItem newItem = new ListItem( answers[i].text );<BR> // Tried this too but no luck :(<BR> newItem.Attributes.Add( "value", answers[i].text );<BR> myList.Items.Add( newItem );<BR>}<BR><BR><BR>Pete

  2. #2
    Join Date
    Dec 1969

    Default RE: CheckBoxList not writting out values

    Hey, I&#039;m not sure will it help or not, but you can try:<BR>some your loop...<BR>for ()<BR>{<BR><BR>myList.Items.Add(new ListItem("Text","Value"));<BR><BR>}<BR><BR>that have to work, I usually use such code.<BR><BR>Best regards,<BR>Alex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts