asp.net - How to deny dynamic name generation when creating a checkbox list dynamically -


im creating checkbox list htmlinputcheckbox based on database entries.

due validation purposes it's required checkboxes has same name.

unfortunately name attributes dynamically generated.

any suggestions?

code:

        foreach (var item in tableitems)         {             index += 1;                           var value = item.getstringvalue("text", string.empty);              var checkbox = new htmlinputcheckbox();             checkbox.name = this.id;  //<-- has same checkboxes                             checkbox.attributes.add("class", checkboxcssclasses);             checkbox.id = this.id + index;             checkbox.attributes.add("value", value);             if (required == true)                 checkbox.attributes.add("required", "required");             dynamiccheckboxes.controls.add(checkbox);              var label = new htmlgenericcontrol("label");             label.attributes.add("class", labelcssclasses);             label.attributes.add("for", this.id + index);             label.innerhtml = value;             dynamiccheckboxes.controls.add(label);                         } 


Comments