<asp:Repeater ID="RepeaterEmailList" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="1" cellspacing="0" width="96.5%">
<tr>
<td>
</td>
<td>
Nickname
</td>
<td>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="height:10px; line-height:10px;">
<td>
<!--下面這個(gè)CheckBox的ID,注意喔,因?yàn)楹笈_(tái)需要用到它-->
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
<td>
<%# Eval("nickname")%>
</td>
<td>
<!--下面這個(gè)Label的ID,注意喔,因?yàn)楹笈_(tái)需要用到它-->
<asp:Label ID="Label1" runat="server" Text=' <%# Eval("mail")%>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
下面Insus.NET將會(huì)寫一個(gè)方法,也許你的專案不止一個(gè)地方使用到,在需要的地方直接調(diào)用即可。
GetCheckBoxSelectedValue
代碼如下:
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;
}
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com