asp.net - Add Event on a dynamic Input Control in an ItemTemplate -


i have list of products displayed input (checkbox) , need add event every time product selected, using asp.net in vb.net.

<itemtemplate>     <table border="0" cellpadding="0" cellspacing="0" align="left">                         <tr>             <td align="center" class="price" width = "200">                 <input id="checkbox1" type="checkbox" name="<%#eval("productcode").tostring%>" runat="server"/>             </td>        </tr>    </table> </itemtemplate> 

you can add code asp:checkbox , use oncheckedchanged property remember set autopostback true. can not set id dynamic value, can set hidden field , use

e.g

<asp:checkbox id="cb1" runat="server" oncheckedchanged="checkbox_click" autopostback="true"/> <asp:hiddenfield id="hd1" runat="server" value='<%# eval("productcode") %>' /> 

then in code behind

protected sub checkbox_click(sender object, e eventargs)      dim s checkbox = ctype(sender, checkbox)      dim hd hiddenfield = s.namingcontainer.findcontrol("hd1")      dim productcode string = hd.value   end sub 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -