Users Pricing

forum

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

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

mohan kumar 9535 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!!!!

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md