m

m

  • NA
  • 30
  • 0

Problem building a class (i think)

Sep 3 2008 1:10 PM
I'm making an asp.net site and am learning C# as I go. I'm having an issue with storing the state of some checkboxes that are in a GridView control.

The code works fine when I store the state of 2 checkboxes, but when I try to store the state of 3 check boxes, I get the following error:

CS1729: 'CheckBoxState' does not contain a constructor that takes '3' arguments

Here's my code:

    protected Dictionary<int, CheckBoxState> checkBoxState;

    protected void grdOrders_Sorting(object sender, GridViewSortEventArgs e)
    {
        // Save checkbox states before sorting.  State is saved here to maintain through sorting.
        //   If this is required through other events as well, may need to do this somewhere else
        //   (e.g. Page_Load for each post).

        // Create new Dictionary object to hold checkbox states
        this.checkBoxState = new Dictionary<int, CheckBoxState>();

        // Loop through each row in the GridView...
        foreach (GridViewRow row in grdOrders.Rows)
        {
            // Get references to the CheckBoxes
            CheckBox chkDeny = (CheckBox)row.FindControl("chkDeny");
            CheckBox chkApprove = (CheckBox)row.FindControl("chkApprove");
            CheckBox chkNeither = (CheckBox)row.FindControl("chkNeither");
           
            // The default state is both CheckBoxes unchecked, so only save state if one is checked
            if (chkApprove.Checked || chkDeny.Checked || chkNeither.Checked)
            {
                // Get DataKey for reference.  This will be used to retrieve the state later.
                int key = Int32.Parse(grdOrders.DataKeys[row.RowIndex].Value.ToString());

                // Save CheckBox state.
                CheckBoxState state = new CheckBoxState(chkApprove.Checked, chkDeny.Checked, chkNeither.Checked);
                this.checkBoxState.Add(key, state);
            }
        }
    }

Here's the line that errors out:
CheckBoxState state = new CheckBoxState(chkApprove.Checked, chkDeny.Checked, chkNeither.Checked);

Thanks for any help!



Answers (5)