简体   繁体   中英

Add checkbox to each ItemTemplate value

I am binding a List with a size of 5 to a DataList with this code:

 <ItemTemplate>
     <%# Eval("Id") %>
     <%# Eval("FirstName") %>
     <%# Eval("LastName") %>
     <%# Eval("City") %>
 </ItemTemplate>

I would like to add dynamically via code behind a checkbox next to every 5 list items and next to every itemtemplate eval property (Id, FirstName, LastName, City).

I would like to have an output like this (on the ASPX page):

(X)1 (X)Mike (X)A (X)New York

(X)2 (X)John (X)B (X)New York

(X)3 (X)Kevin (X)C (X)New York

(X)4 (X)Oswald (X)D (X)New York

(X)5 (X)Rene (X)E (X)New York

(X) = checkbox

Those checkboxes should have an own unique id.

Can you guys give me some tips on how to do this or redirect me to good sources? I couldn't find anything via Google.

My output at the moment is:

1 Mike A New York

2 John B New York

3 Kevin C New York

4 Oswald D New York

5 Rene E New York

Thanks!

Use: <ItemTemplate>
<asp:CheckBox ID="iDCheckbox" runat="server" Text='<%# Eval("Id") %>'/>                                 
        ...etc...                        
</ItemTemplate>

set Display="inline" if it defaults to blockset Display="inline" if it defaults to block

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM