forum

Home / DeveloperSection / Forums / I need to display my CheckboxList selected items in a label..How to do???

I need to display my CheckboxList selected items in a label..How to do???

mohan kumar 9030 15-Nov-2011
This is my aspx page:-

<div>
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true" 
            onselectedindexchanged="CheckBoxList1_SelectedIndexChanged"
          >
        </asp:CheckBoxList>
        <br />
        <br />
        <asp:Label ID="lblChkSelItems" runat="server"></asp:Label>
    </div>

This is my code behind page:-

protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int i=0;
        string msg = "You have selected the following items: ";
        if (CheckBoxList1.Items[i].Selected)
        {
            msg = msg + CheckBoxList1.Items[i].Text + "<br>";
          
        }
        lblChkSelItems.Text = msg;
    }

Even after enabling autopostback option as true,i cant get my required result.. Help me out guyz!!!!

c# c# 
Updated on 15-Nov-2011
Having around 5 Years experience in .NET domain.

Can you answer this question?


Answer

1 Answers

Liked By