0

I have this code. It always gives fales for 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 is bound to a data source and its working.

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 + ", ";
        }
    }
}

any idea whats wrong? thanx..

Darshana
  • 2,462
  • 6
  • 28
  • 54

1 Answers1

2

try this...

for (int i = 0; i < interestedIN.Items.Count; i++)
{
   if (interestedIN.Items[i].Selected)
   {
       values += interestedIN.Items[i].Value + ",";
   }
}

values = values.TrimEnd(',');
highwingers
  • 1,649
  • 4
  • 21
  • 39