The Repeater control. Each item has a CheckBox before it displays the selected item column.
In this method, you can see the line of highlight after the selection, this function can refer to this link: http://www.jb51.net/article/33455.htm
The following is the Repeater control Html. There are two things to note: CheckBox and Label. This Label varies with the content you need. If you want to obtain the nick name, you need to put the bound content on the Label.
Repeater & CheckBox
Copy codeThe Code is as follows:
<Asp: Repeater ID = "RepeaterEmailList" runat = "server">
<HeaderTemplate>
<Table border = "1" cellpadding = "1" cellspacing = "0" width = "96.5%">
<Tr>
<Td>
</Td>
<Td>
Nickname
</Td>
<Td>
Email
</Td>
</Tr>
</HeaderTemplate>
<ItemTemplate>
<Tr style = "height: 10px; line-height: 10px;">
<Td>
<! -- The ID of the CheckBox below. Note that it is used in the background -->
<Asp: CheckBox ID = "CheckBox1" runat = "server"/>
</Td>
<Td>
<% # Eval ("nickname") %>
</Td>
<Td>
<! -- Note the ID of the Label below, because it is needed in the background -->
<Asp: Label ID = "Label1" runat = "server" Text = '<% # Eval ("mail") %>'> </asp: Label>
</Td>
</Tr>
</ItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</Asp: Repeater>
The following Insus. NET will write a method. Maybe your project is used in more than one place and can be called directly as needed.
GetCheckBoxSelectedValue
Copy codeThe Code is as follows:
Private string GetCheckBoxSelectedValue (Repeater repeater, string checkBoxId, string labelId)
{
String tempValue = string. Empty;
Foreach (RepeaterItem item in repeater. Items)
{
If (item. ItemType = ListItemType. Item | item. ItemType = ListItemType. AlternatingItem)
{
If (item. FindControl (checkBoxId )! = Null & item. FindControl (labelId )! = Null)
{
CheckBox cb = (CheckBox) item. FindControl (checkBoxId );
Label lbl = (Label) item. FindControl (labelId );
If (cb. Checked)
{
TempValue = tempValue + ";" + lbl. Text;
}
}
}
}
If (tempValue. Length> 0)
{
TempValue = tempValue. Substring (2 );
}
Return tempValue;
}