I playing around with this new software Visual Studio Express 2010 using C# and I have the source code files but what I am wanting to do is on this Greeting Card Maker. I would like to have some check boxes so the user can Select a Prefined Message to be displayed on the Greeting Card.

<asp:Checkbox ID = "chklst" runat="server" />

This is the .aspx file, then on my .aspx.cs file I have this

protected void Page_Load(object sender, System.EventArgs e)
{
    if (this.IsPostBack == false)
    {
        //Get the Selected Greeting.
        chklst.Items.Add("Happy Birthday");
        chklst.Items.Add("Happy Happy Birtyday");
        }

I am not sure what else I should do.

Recommended Answers

All 3 Replies

I think you maybe confusing the checkbox for a checkboxlist control.

If you have a static list of checkboxes, I don't see the advantage of using code behind unless you are generating the checkboxes from a datasource. But it seems like in your case you are trying to group checkboxes to treat them as a group....

Take a look at this summary:
CheckBox and CheckBoxList Web Server Controls Overview

Change <asp:Checkbox ID = "chklst" runat="server" /> to
<asp:CheckBoxList ID="chklst" runat="server" AutoPostBack = "true"></asp:CheckBoxList>

To add to it, do this in your .cs file

chklst.Items.Add('Happy Birthday');
chklst.Items.Add('Happy Happy Birthday');

Thank you Ggamble.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.