Checkboxes and Multiple Defaults

1 posts, 0 answers
  1. Mike
    Mike avatar
    338 posts
    Member since:
    Jun 2008

    Posted 27 Apr 2013 Link to this post

    I figured out how to set defaults for the multiple check boxes.

    Here is my example:

    DataTable tableMonths = new DataTable();
    tableMonths.Columns.Add("name", typeof(int));
    tableMonths.Columns.Add("value", typeof(string));
    tableMonths.Rows.Add(12, "12");
    tableMonths.Rows.Add(24, "24");
    tableMonths.Rows.Add(36, "36");
    tableMonths.Rows.Add(48, "48");
    tableMonths.Rows.Add(60, "60");
    tableMonths.Rows.Add(72, "72");
    RadComboBoxMonths.DataSource = tableMonths;
    RadComboBoxMonths.DataTextField = "name";
    RadComboBoxMonths.DataValueField = "value";
    RadComboBoxMonths.DataBind();
    // preselect these terms by default
    RadComboBoxMonths.SelectedValue = "12";
    RadComboBoxItem twelveMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;
    twelveMonths.Checked = true;
    RadComboBoxMonths.SelectedValue = "24";
    RadComboBoxItem twentyFourMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;
    twentyFourMonths.Checked = true;
    RadComboBoxMonths.SelectedValue = "36";
    RadComboBoxItem thritySixMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;
    thritySixMonths.Checked = true;
Back to Top