mardi 26 octobre 2021

How to dynamically assign ID to a checkbox in a for-each cycle

I have the following code in a ascx : i run a SQL query and I put it in a Datatable. Then I show the values in the page like this

<% For each row As DataRow In myDataTable.Rows %>

    <%=row("something") %>
    <%=row("somethingelse") %>
    <asp:CheckBox ID="CheckBox1" runat="server" />

<% next %>

Now... how can I set the ID of the checkbox dymanically? something like

<asp:CheckBox ID="<%=row("MyId")%>" runat="server" />

that obviously do not work.

I need to set the id as the value I get from the DB so if it is checked I can pass the checked id to another page.




Aucun commentaire:

Enregistrer un commentaire