我有这个代码。它总是fales
为item.Selected
<asp:Literal ID="LiteralEmployeeList" runat="server" />
<asp:LinkButton ID="LinkButtonRecipients" runat="server">Add/Remove Recipients</asp:LinkButton>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderTo" runat="server" TargetControlID="LinkButtonRecipients"
DropShadow="true" PopupControlID="PanelEmployeeList" OkControlID="ButtonOk" EnableViewState="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="PanelEmployeeList" runat="server" Width="200" Height="100" ScrollBars="Vertical">
<div id="DivPanelBody">
<div id="DivList">
<asp:CheckBoxList ID="CheckBoxListEmployee" runat="server" EnableViewState="true"
onselectedindexchanged="CheckBoxListEmployee_SelectedIndexChanged">
</asp:CheckBoxList>
</div>
<div id="DivControls">
<asp:Button ID="ButtonOk" runat="server" Text="Ok" />
</div>
</div>
</asp:Panel>
CheckBoxList
绑定到数据源及其工作。
protected void CheckBoxListEmployee_SelectedIndexChanged(object sender, EventArgs e)
{
LiteralEmployeeList.Text = string.Empty;
foreach (ListItem item in CheckBoxListEmployee.Items)
{
if (item.Selected)
{
LiteralEmployeeList.Text += item.Text + ", ";
}
}
}
知道有什么问题吗?谢谢。。