0

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.

3
Contributors
3
Replies
20
Views
3 Years
Discussion Span
Last Post by dlmagers
0

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

0

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');

Edited by ggamble

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.