简体   繁体   English

将复选框添加到每个ItemTemplate值

[英]Add checkbox to each ItemTemplate value

I am binding a List with a size of 5 to a DataList with this code: 我使用以下代码将大小为5的列表绑定到DataList

 <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). 我想通过代码在每5个列表项旁边和每个itemtemplate eval属性(Id,FirstName,LastName,City)旁边的复选框后面动态添加代码。

I would like to have an output like this (on the ASPX page): 我想要这样的输出(在ASPX页面上):

(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 (X)=复选框

Those checkboxes should have an own unique id. 这些复选框应具有自己的唯一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. 我无法通过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 如果默认为block,则设置Display =“ inline”;如果默认为block,则设置Display =“ inline”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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